From: Shakeel Butt <shakeel.butt@linux.dev>
To: Keren Sun <kerensun@google.com>
Cc: akpm@linux-foundation.org, roman.gushchin@linux.dev,
hannes@cmpxchg.org, mhocko@kernel.org, muchun.song@linux.dev,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] mm: Replace simple_strtoul() with kstrtoul()
Date: Tue, 5 Nov 2024 08:38:32 -0800 [thread overview]
Message-ID: <md72ehlg7qbaexaxypl7tzmstshs24uqgfegyrkbx5lxm5pmq2@4opgtkva3eh3> (raw)
In-Reply-To: <20241104222737.298130-5-kerensun@google.com>
On Mon, Nov 04, 2024 at 02:27:37PM -0800, Keren Sun wrote:
> simple_strtoul() has caveat and is obsolete, use kstrtoul() instead in mmcg.
Did you test this patch? I don't think kstrtoul() can be used here as it
expects a string containing a single number.
>
> Signed-off-by: Keren Sun <kerensun@google.com>
> ---
> mm/memcontrol-v1.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/mm/memcontrol-v1.c b/mm/memcontrol-v1.c
> index 5e1854623824..260b356cea5a 100644
> --- a/mm/memcontrol-v1.c
> +++ b/mm/memcontrol-v1.c
> @@ -1,5 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0-or-later
>
> +#include "linux/kstrtox.h"
> #include <linux/memcontrol.h>
> #include <linux/swap.h>
> #include <linux/mm_inline.h>
> @@ -1922,17 +1923,15 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of,
>
> buf = strstrip(buf);
>
> - efd = simple_strtoul(buf, &endp, 10);
> - if (*endp != ' ')
> + kstrtoul(buf, 10, efd);
> + if (*buf != ' ')
> return -EINVAL;
> - buf = endp + 1;
> + buf++;
>
> - cfd = simple_strtoul(buf, &endp, 10);
> - if (*endp == '\0')
> - buf = endp;
> - else if (*endp == ' ')
> - buf = endp + 1;
> - else
> + kstrtoul(buf, 10, cfd);
> + if (*buf == ' ')
> + buf++;
> + else if (*buf != '\0')
> return -EINVAL;
>
> event = kzalloc(sizeof(*event), GFP_KERNEL);
> --
> 2.47.0.163.g1226f6d8fa-goog
>
next prev parent reply other threads:[~2024-11-05 16:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-04 22:27 [PATCH 0/4] mm: fix checkpatch.pl warnings in memcg v1 code Keren Sun
2024-11-04 22:27 ` [PATCH 1/4] mm: fix quoted strings spliting across lines Keren Sun
2024-11-05 1:55 ` Shakeel Butt
2024-11-05 21:23 ` Keren Sun
2024-11-04 22:27 ` [PATCH 2/4] mm: Fix minor formatting issues for mm control Keren Sun
2024-11-05 16:29 ` Shakeel Butt
2024-11-04 22:27 ` [PATCH 3/4] mm: Prefer 'unsigned int' to bare use of 'unsigned' Keren Sun
2024-11-05 16:31 ` Shakeel Butt
2024-11-04 22:27 ` [PATCH 4/4] mm: Replace simple_strtoul() with kstrtoul() Keren Sun
2024-11-05 4:39 ` kernel test robot
2024-11-05 5:00 ` kernel test robot
2024-11-05 6:44 ` kernel test robot
2024-11-05 16:38 ` Shakeel Butt [this message]
2024-11-05 19:56 ` Keren Sun
2024-11-07 17:20 ` Roman Gushchin
2024-11-07 17:49 ` Keren Sun
2024-11-05 0:31 ` [PATCH 0/4] mm: fix checkpatch.pl warnings in memcg v1 code Matthew Wilcox
2024-11-05 0:44 ` Roman Gushchin
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=md72ehlg7qbaexaxypl7tzmstshs24uqgfegyrkbx5lxm5pmq2@4opgtkva3eh3 \
--to=shakeel.butt@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kerensun@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
/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