From: David Hildenbrand <david@redhat.com>
To: xu.xin16@zte.com.cn, akpm@linux-foundation.org
Cc: willy@infradead.org, shy828301@gmail.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH linux-next] mm/huge_memory: remove redundant locking when parsing THP sysfs input
Date: Mon, 13 May 2024 17:58:21 +0200 [thread overview]
Message-ID: <baa40403-e498-4db8-ac47-126e7d3869c8@redhat.com> (raw)
In-Reply-To: <20240511144048767fdB7EqYoMHEw6A5b6FrXM@zte.com.cn>
On 11.05.24 08:40, xu.xin16@zte.com.cn wrote:
> From: Ran Xiaokai <ran.xiaokai@zte.com.cn>
>
> Since sysfs_streq() only performs a simple memory comparison operation
> and will not introduce any sleepable operation, So there is no
> need to drop the lock when parsing input. Remove redundant lock
> and unlock operations to make code cleaner.
>
> Signed-off-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
> ---
> mm/huge_memory.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 89f58c7603b2..87123a87cb21 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -478,32 +478,26 @@ static ssize_t thpsize_enabled_store(struct kobject *kobj,
> int order = to_thpsize(kobj)->order;
> ssize_t ret = count;
>
> + spin_lock(&huge_anon_orders_lock);
> if (sysfs_streq(buf, "always")) {
> - spin_lock(&huge_anon_orders_lock);
> clear_bit(order, &huge_anon_orders_inherit);
> clear_bit(order, &huge_anon_orders_madvise);
> set_bit(order, &huge_anon_orders_always);
> - spin_unlock(&huge_anon_orders_lock);
> } else if (sysfs_streq(buf, "inherit")) {
> - spin_lock(&huge_anon_orders_lock);
> clear_bit(order, &huge_anon_orders_always);
> clear_bit(order, &huge_anon_orders_madvise);
> set_bit(order, &huge_anon_orders_inherit);
> - spin_unlock(&huge_anon_orders_lock);
> } else if (sysfs_streq(buf, "madvise")) {
> - spin_lock(&huge_anon_orders_lock);
> clear_bit(order, &huge_anon_orders_always);
> clear_bit(order, &huge_anon_orders_inherit);
> set_bit(order, &huge_anon_orders_madvise);
> - spin_unlock(&huge_anon_orders_lock);
> } else if (sysfs_streq(buf, "never")) {
> - spin_lock(&huge_anon_orders_lock);
> clear_bit(order, &huge_anon_orders_always);
> clear_bit(order, &huge_anon_orders_inherit);
> clear_bit(order, &huge_anon_orders_madvise);
> - spin_unlock(&huge_anon_orders_lock);
> } else
> ret = -EINVAL;
> + spin_unlock(&huge_anon_orders_lock);
>
> return ret;
> }
No strong opinion
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
prev parent reply other threads:[~2024-05-13 16:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-11 6:40 xu.xin16
2024-05-11 16:05 ` Matthew Wilcox
2024-05-11 21:35 ` Andrew Morton
2024-05-13 15:58 ` David Hildenbrand [this message]
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=baa40403-e498-4db8-ac47-126e7d3869c8@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shy828301@gmail.com \
--cc=willy@infradead.org \
--cc=xu.xin16@zte.com.cn \
/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