From: Tejun Heo <tj@kernel.org>
To: Christophe LEROY <christophe.leroy@c-s.fr>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: sysfs_kf_seq_show() spends 87% of time in memset()
Date: Fri, 15 Dec 2017 05:19:32 -0800 [thread overview]
Message-ID: <20171215131932.GE3919388@devbig577.frc2.facebook.com> (raw)
In-Reply-To: <1855b755-177f-f5be-64b5-3d22e454d3ff@c-s.fr>
Hello,
On Fri, Dec 15, 2017 at 01:59:55PM +0100, Christophe LEROY wrote:
> Doing a 'perf record' on an application using GPIOs a lot, I
> discovered that most of the time spent in the read() system call of
> the 'value' sysfs file of that GPIO (which returns "0\n" or "1\n")
> is indeed spent in memset() zeroing a buffer of size PAGE_SIZE for a
> 2 bytes read:
...
> As far as I can see, that memset() was introduced by your commit
> f5c16f29bf5e5 ("sysfs: make sure read buffer is zeroed")
>
> Is that really necessary, taking into account that the ->show will
> overwrite it ?
We were doing get_zeroed_pages() before, so the commit is restoring
the previous behavior, and, yeah, I think there's some risk of leaking
uninitialized data. The way the ->show() interface is defined doesn't
give us a lot of leeway. The right thing to do would be switching the
said driver to prealloc read or ->bin_read.
Thanks.
--
tejun
prev parent reply other threads:[~2017-12-15 13:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-15 12:59 sysfs_kf_seq_show() spends 87% of time in memset() Christophe LEROY
2017-12-15 13:19 ` Tejun Heo [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=20171215131932.GE3919388@devbig577.frc2.facebook.com \
--to=tj@kernel.org \
--cc=christophe.leroy@c-s.fr \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).