From: David Hildenbrand <david@redhat.com>
To: Shiyang Ruan <ruansy.fnst@fujitsu.com>,
linux-mm@kvack.org, osalvador@suse.de, rafael@kernel.org
Subject: Re: [PATCH v2] drivers/base/memory: simplify outputting of valid_zones_show()
Date: Tue, 7 Jan 2025 11:52:22 +0100 [thread overview]
Message-ID: <589678a4-0257-49d4-a282-91d583ae14b1@redhat.com> (raw)
In-Reply-To: <20250107103926.1189728-1-ruansy.fnst@fujitsu.com>
On 07.01.25 11:39, Shiyang Ruan wrote:
> No need to specific position at the first writing to the buf because the
> @len is always 0 at this time. Use sysfs_emit() instead to simplify it.
> Also avoid setting/checking default_zone with a conditional operator.
>
> Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
> ---
> drivers/base/memory.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
> index 67858eeb92ed..975fdbbff264 100644
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -466,22 +466,18 @@ static ssize_t valid_zones_show(struct device *dev,
> * If !mem->zone, the memory block spans multiple zones and
> * cannot get offlined.
> */
> - default_zone = mem->zone;
> - if (!default_zone)
> - return sysfs_emit(buf, "%s\n", "none");
> - len += sysfs_emit_at(buf, len, "%s", default_zone->name);
> - goto out;
> + return sysfs_emit(buf, "%s\n",
> + mem->zone ? mem->zone->name : "none");
> }
>
> default_zone = zone_for_pfn_range(MMOP_ONLINE, nid, group,
> start_pfn, nr_pages);
>
> - len += sysfs_emit_at(buf, len, "%s", default_zone->name);
> + len += sysfs_emit(buf, "%s", default_zone->name);
Sorry for realizing it now:
you can turn that into
len = sysfs_emit(buf, "%s", default_zone->name);
And stop initializing len to 0.
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-01-07 10:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 10:09 [PATCH] " Shiyang Ruan
2025-01-07 10:15 ` David Hildenbrand
2025-01-07 10:28 ` Shiyang Ruan
2025-01-07 10:33 ` David Hildenbrand
2025-01-07 10:39 ` [PATCH v2] " Shiyang Ruan
2025-01-07 10:52 ` David Hildenbrand [this message]
2025-01-08 1:52 ` [PATCH v3] " Shiyang Ruan
2025-01-22 10:14 ` Shiyang Ruan
2025-01-22 11:04 ` David Hildenbrand
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=589678a4-0257-49d4-a282-91d583ae14b1@redhat.com \
--to=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--cc=rafael@kernel.org \
--cc=ruansy.fnst@fujitsu.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