From: Qianfeng Rong <rongqianfeng@vivo.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Jyoti Bhayana" <jbhayana@google.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: common: scmi_iio: use kcalloc() instead of kzalloc()
Date: Tue, 19 Aug 2025 20:25:04 +0800 [thread overview]
Message-ID: <19a2d3da-a543-4a2f-8b2b-8d1e6088387f@vivo.com> (raw)
In-Reply-To: <CAHp75VecWJXd-kP8mhFtFZpiU-qcW3_nQz=w1Addq7SHTv=SSQ@mail.gmail.com>
在 2025/8/19 18:13, Andy Shevchenko 写道:
> [You don't often get email from andy.shevchenko@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> On Tue, Aug 19, 2025 at 1:08 PM Qianfeng Rong <rongqianfeng@vivo.com> wrote:
>> 在 2025/8/19 17:46, Andy Shevchenko 写道:
>>> On Tue, Aug 19, 2025 at 11:56 AM Qianfeng Rong <rongqianfeng@vivo.com> wrote:
> ...
>
>>> While this change is correct...
>>>> sensor->freq_avail =
>>>> - devm_kzalloc(&iio_dev->dev,
>>>> - sizeof(*sensor->freq_avail) *
>>>> - (sensor->sensor_info->intervals.count * 2),
>>>> + devm_kcalloc(&iio_dev->dev,
>>>> + sensor->sensor_info->intervals.count * 2,
>>> ...I would also switch this to use array_size() instead of explicit
>>> multiplication as it will check for boundaries that are not static in
>>> this case.
>> I don't understand what "will check for boundaries that are not static in
>> this case" means. Could you explain it to me?
> intervals.count may be anything and of any type. Compiler may or may
> not proof that it holds the value less than size_t / 2 (which may be
> == int / 2 on 32-bit platforms). That's why it's better to use
> array_size(intervals.count, 2),
Sorry, I just understood your reply, I will send v2 immediately. :)
>
>> I've experimented with the following command and found that kmalloc_array()
>> generates fewer instructions than kmalloc(array_size()):
>> objdump -dSl --prefix-addresses <changed module>.o
> It's about the second parameter in devm_kcalloc(), and of course it
> may generate less instructions but it's irrelevant to my comment.
>
>
Best regards,
Qianfeng
prev parent reply other threads:[~2025-08-19 12:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-19 8:55 Qianfeng Rong
2025-08-19 9:46 ` Andy Shevchenko
2025-08-19 10:07 ` Qianfeng Rong
2025-08-19 10:13 ` Andy Shevchenko
2025-08-19 12:00 ` Qianfeng Rong
2025-08-19 12:25 ` Qianfeng Rong [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=19a2d3da-a543-4a2f-8b2b-8d1e6088387f@vivo.com \
--to=rongqianfeng@vivo.com \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jbhayana@google.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.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
all inboxes | Powered by JetHome®