mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Nanzhe Zhao <zhaonanzhe@xiaomi.com>
Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
	Barry Song <baohua@kernel.org>, Juan Yescas <jyescas@google.com>,
	Dev Jain <Dev.Jain@arm.com>,
	linux-kernel@vger.kernel.org,
	David Hildenbrand <David.Hildenbrand@arm.com>,
	Bo Zhang <zhangbo56@xiaomi.com>,
	Kalesh Singh <kaleshsingh@google.com>,
	Ryan Roberts <Ryan.Roberts@arm.com>,
	Jaegeuk Kim <jaegeuk@kernel.org>,
	Pengfei Li <lipengfei28@xiaomi.com>
Subject: Re: [f2fs-dev] [RFC PATCH v2 01/10] f2fs: extend folio state for large folio write path
Date: Fri, 10 Jul 2026 11:05:56 +0800	[thread overview]
Message-ID: <aed78e9a-18f8-46a7-9806-6edd1e0f9932@kernel.org> (raw)
In-Reply-To: <20260710011534.2307696-2-zhaonanzhe@xiaomi.com>

On 7/10/26 09:15, Nanzhe Zhao wrote:
>> Seems there are redundant codes below, let's have a try to wrap them w/ a macro for cleanup?
> 
> Got it, thanks!
> How about the following example implementation?

Good, please go ahead.

Thanks,

> 
> static inline unsigned long f2fs_folio_get_private_flags(const struct folio *folio)
> {
> 	if (f2fs_folio_has_state(folio)) {
> 		struct f2fs_folio_state *ffs = folio->private;
> 
> 		return ffs->private_flags;
> 	}
> 
> 	return (unsigned long)folio->private;
> }
> 
> static inline void f2fs_folio_set_private_flags(struct folio *folio,
> 						unsigned long flags)
> {
> 	if (f2fs_folio_has_state(folio)) {
> 		struct f2fs_folio_state *ffs = folio->private;
> 
> 		ffs->private_flags |= flags;
> 		return;
> 	}
> 
> 	if (!folio_test_private(folio))
> 		folio_attach_private(folio, (void *)flags);
> 	else
> 		folio->private = (void *)((unsigned long)folio->private | flags);
> }
> 
> static inline void f2fs_folio_clear_private_flags(struct folio *folio,
> 						 unsigned long flags)
> {
> 	unsigned long private;
> 
> 	if (f2fs_folio_has_state(folio)) {
> 		struct f2fs_folio_state *ffs = folio->private;
> 
> 		ffs->private_flags &= ~flags;
> 		return;
> 	}
> 
> 	private = (unsigned long)folio->private;
> 	private &= ~flags;
> 	if (private == BIT(PAGE_PRIVATE_NOT_POINTER))
> 		folio_detach_private(folio);
> 	else
> 		folio->private = (void *)private;
> }
> 
> #define PAGE_PRIVATE_GET_FUNC(name, flagname) \
> static inline bool folio_test_f2fs_##name(const struct folio *folio)\
> {\
> 	unsigned long priv = f2fs_folio_get_private_flags(folio);\
> 	unsigned long v = (1UL << PAGE_PRIVATE_NOT_POINTER) |\
> 			     (1UL << PAGE_PRIVATE_##flagname);\
> 	return (priv & v) == v;\
> }\
> static inline bool page_private_##name(struct page *page)\
> {\
> 	return PagePrivate(page) &&\
> 		test_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page)) &&\
> 		test_bit(PAGE_PRIVATE_##flagname, &page_private(page));\
> }
> 
> #define PAGE_PRIVATE_SET_FUNC(name, flagname) \
> static inline void folio_set_f2fs_##name(struct folio *folio)\
> {\
> 	unsigned long v = (1UL << PAGE_PRIVATE_NOT_POINTER) |\
> 			     (1UL << PAGE_PRIVATE_##flagname);\
> 	f2fs_folio_set_private_flags(folio, v);\
> }\
> static inline void set_page_private_##name(struct page *page)\
> {\
> 	if (!PagePrivate(page))\
> 		attach_page_private(page, (void *)0);\
> 	set_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page));\
> 	set_bit(PAGE_PRIVATE_##flagname, &page_private(page));\
> }
> 
> #define PAGE_PRIVATE_CLEAR_FUNC(name, flagname) \
> static inline void folio_clear_f2fs_##name(struct folio *folio)\
> {\
> 	f2fs_folio_clear_private_flags(folio,\
> 			1UL << PAGE_PRIVATE_##flagname);\
> }\
> static inline void clear_page_private_##name(struct page *page)\
> {\
> 	clear_bit(PAGE_PRIVATE_##flagname, &page_private(page));\
> 	if (page_private(page) == BIT(PAGE_PRIVATE_NOT_POINTER))\
> 		detach_page_private(page);\
> }
> 


  parent reply	other threads:[~2026-07-10  3:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22 16:08 [f2fs-dev] [RFC PATCH v2 00/10] f2fs: support & optimize large folios for writable files Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 01/10] f2fs: extend folio state for large folio write path Nanzhe Zhao
2026-06-30  7:37   ` Chao Yu
     [not found]     ` <20260710011534.2307696-2-zhaonanzhe@xiaomi.com>
2026-07-10  3:05       ` Chao Yu [this message]
2026-07-06  7:43   ` Nanzhe Zhao
2026-07-06  7:53   ` Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 02/10] f2fs: carry subpage offset and count in write IO Nanzhe Zhao
2026-06-30  8:38   ` Chao Yu
2026-07-10  1:15     ` Nanzhe Zhao
2026-07-10  3:04       ` Chao Yu
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 03/10] f2fs: support regular file buffered writes on large folios Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 04/10] f2fs: support atomic file large folios buffered write Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 05/10] f2fs: support large folio writeback Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 06/10] f2fs: prepare mmap write faults for large folios Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 07/10] f2fs: make GC migration large-folio aware Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 08/10] f2fs: allow large folio support to writeable files Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 09/10] f2fs: optimize small block size large folio read Nanzhe Zhao
2026-06-22 16:08 ` [f2fs-dev] [RFC PATCH v2 10/10] f2fs: support partial uptodate " Nanzhe Zhao
2026-07-01  2:51 ` [f2fs-dev] [RFC PATCH v2 00/10] f2fs: support & optimize large folios for writable files Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aed78e9a-18f8-46a7-9806-6edd1e0f9932@kernel.org \
    --to=chao@kernel.org \
    --cc=David.Hildenbrand@arm.com \
    --cc=Dev.Jain@arm.com \
    --cc=Ryan.Roberts@arm.com \
    --cc=baohua@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=jyescas@google.com \
    --cc=kaleshsingh@google.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lipengfei28@xiaomi.com \
    --cc=zhangbo56@xiaomi.com \
    --cc=zhaonanzhe@xiaomi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox