On 5/19/20 12:06 PM, Gao Xiang wrote:
On Tue, May 19, 2020 at 09:35:59AM +0200, Guoqing Jiang wrote:
On 5/19/20 7:12 AM, Andrew Morton wrote:
On Sun, 17 May 2020 23:47:18 +0200 Guoqing Jiang <guoqing.jiang@xxxxxxxxxxxxxxx> wrote:
We can cleanup code a little by call detach_page_private here.
...
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -804,10 +804,7 @@ static int __buffer_migrate_page(struct address_space *mapping,
if (rc != MIGRATEPAGE_SUCCESS)
goto unlock_buffers;
- ClearPagePrivate(page);
- set_page_private(newpage, page_private(page));
- set_page_private(page, 0);
- put_page(page);
+ set_page_private(newpage, detach_page_private(page));
get_page(newpage);
bh = head;
mm/migrate.c: In function '__buffer_migrate_page':
./include/linux/mm_types.h:243:52: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
#define set_page_private(page, v) ((page)->private = (v))
^
mm/migrate.c:800:2: note: in expansion of macro 'set_page_private'
set_page_private(newpage, detach_page_private(page));
^~~~~~~~~~~~~~~~
The fact that set_page_private(detach_page_private()) generates a type
mismatch warning seems deeply wrong, surely.
Please let's get the types sorted out - either unsigned long or void *,
not half-one and half-the other. Whatever needs the least typecasting
at callsites, I suggest.
Sorry about that, I should notice the warning before. I will double check if
other
places need the typecast or not, then send a new version.
And can we please implement set_page_private() and page_private() with
inlined C code? There is no need for these to be macros.
Just did a quick change.
-#define page_private(page)Â Â Â Â Â Â Â Â Â Â Â Â ((page)->private)
-#define set_page_private(page, v)Â Â Â Â Â ((page)->private = (v))
+static inline unsigned long page_private(struct page *page)
+{
+Â Â Â Â Â Â return page->private;
+}
+
+static inline void set_page_private(struct page *page, unsigned long
priv_data)
+{
+Â Â Â Â Â Â page->private = priv_data;
+}
Then I get error like.
fs/erofs/zdata.h: In function ‘z_erofs_onlinepage_index’:
fs/erofs/zdata.h:126:8: error: lvalue required as unary ‘&’ operand
 u.v = &page_private(page);
       ^
I guess it is better to keep page_private as macro, please correct me in
case I
missed something.
I guess that you could Cc me in the reply.
Sorry for not do that ...
In that case, EROFS uses page->private as an atomic integer to
trace 2 partial subpages in one page.
I think that you could also use &page->private instead directly to
replace &page_private(page) here since I didn't find some hint to
pick &page_private(page) or &page->private.
Thanks for the input, I just did a quick test, so need to investigate more.
And I think it is better to have another thread to change those macros to
inline function, then fix related issues due to the change.
In addition, I found some limitation of new {attach,detach}_page_private
helper (that is why I was interested in this series at that time [1] [2],
but I gave up finally) since many patterns (not all) in EROFS are
io_submit (origin, page locked):
attach_page_private(page);
...
put_page(page);
end_io (page locked):
SetPageUptodate(page);
unlock_page(page);
since the page is always locked, so io_submit could be simplified as
set_page_private(page, ...);
SetPagePrivate(page);
, which can save both one temporary get_page(page) and one
put_page(page) since it could be regarded as safe with page locked.
The SetPageUptodate is not called inside {attach,detach}_page_private,
I could probably misunderstand your point, maybe you want the new pairs
can handle the locked page, care to elaborate more?
btw, I noticed the patchset versions are PATCH [3], RFC PATCH [4],
RFC PATCH v2 [5], RFC PATCH v3 [6], PATCH [7]. Although I also
noticed the patchset title was once changed, but it could be some
harder to trace the whole history discussion.
[1] https://lore.kernel.org/linux-fsdevel/20200419051404.GA30986@hsiangkao-HP-ZHAN-66-Pro-G1/
[2] https://lore.kernel.org/linux-fsdevel/20200427025752.GA3979@hsiangkao-HP-ZHAN-66-Pro-G1/
[3] https://lore.kernel.org/linux-fsdevel/20200418225123.31850-1-guoqing.jiang@xxxxxxxxxxxxxxx/
[4] https://lore.kernel.org/linux-fsdevel/20200426214925.10970-1-guoqing.jiang@xxxxxxxxxxxxxxx/
[5] https://lore.kernel.org/linux-fsdevel/20200430214450.10662-1-guoqing.jiang@xxxxxxxxxxxxxxx/
[6] https://lore.kernel.org/linux-fsdevel/20200507214400.15785-1-guoqing.jiang@xxxxxxxxxxxxxxx/
[7] https://lore.kernel.org/linux-fsdevel/20200517214718.468-1-guoqing.jiang@xxxxxxxxxxxxxxx/
All the cover letter of those series are here.
RFC V3:https://lore.kernel.org/lkml/20200507214400.15785-1-guoqing.jiang@xxxxxxxxxxxxxxx/
RFC V2:https://lore.kernel.org/lkml/20200430214450.10662-1-guoqing.jiang@xxxxxxxxxxxxxxx/
RFC:https://lore.kernel.org/lkml/20200426214925.10970-1-guoqing.jiang@xxxxxxxxxxxxxxx/
And the latest one:
https://lore.kernel.org/lkml/20200430214450.10662-1-guoqing.jiang@xxxxxxxxxxxxxxx/
Thanks,
Guoqing