mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Liu Ye <liuyerd@163.com>, akpm@linux-foundation.org
Cc: willy@infradead.org, ran.xiaokai@zte.com.cn,
	dan.carpenter@linaro.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, Liu Ye <liuye@kylinos.cn>
Subject: Re: [PATCH] fs/proc/page: Refactoring to reduce code duplication.
Date: Mon, 17 Mar 2025 09:56:47 +0100	[thread overview]
Message-ID: <1c7018f1-fdc5-4fc6-adc7-fae592851710@redhat.com> (raw)
In-Reply-To: <20250317080118.95696-1-liuyerd@163.com>

On 17.03.25 09:01, Liu Ye wrote:
> From: Liu Ye <liuye@kylinos.cn>
> 
> The function kpageflags_read and kpagecgroup_read is quite similar
> to kpagecount_read. Consider refactoring common code into a helper
> function to reduce code duplication.
> 
> Signed-off-by: Liu Ye <liuye@kylinos.cn>
> ---
>   fs/proc/page.c | 158 ++++++++++++++++---------------------------------
>   1 file changed, 50 insertions(+), 108 deletions(-)
> 
> diff --git a/fs/proc/page.c b/fs/proc/page.c
> index a55f5acefa97..f413016ebe67 100644
> --- a/fs/proc/page.c
> +++ b/fs/proc/page.c
> @@ -37,19 +37,17 @@ static inline unsigned long get_max_dump_pfn(void)
>   #endif
>   }
>   
> -/* /proc/kpagecount - an array exposing page mapcounts
> - *
> - * Each entry is a u64 representing the corresponding
> - * physical page mapcount.
> - */
> -static ssize_t kpagecount_read(struct file *file, char __user *buf,
> -			     size_t count, loff_t *ppos)
> +static ssize_t kpage_read(struct file *file, char __user *buf,
> +		size_t count, loff_t *ppos,
> +		u64 (*get_page_info)(struct page *))

Can we just indicate using an enum which operation to perform, so we can 
avoid having+passing these functions?

-- 
Cheers,

David / dhildenb


  reply	other threads:[~2025-03-17  8:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-17  8:01 Liu Ye
2025-03-17  8:56 ` David Hildenbrand [this message]
2025-03-17  9:13   ` Liu Ye
2025-03-17  9:18     ` David Hildenbrand
2025-03-17  9:31       ` Liu Ye

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=1c7018f1-fdc5-4fc6-adc7-fae592851710@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dan.carpenter@linaro.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuye@kylinos.cn \
    --cc=liuyerd@163.com \
    --cc=ran.xiaokai@zte.com.cn \
    --cc=willy@infradead.org \
    /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

all inboxes | Powered by JetHome®