From: Dave Hansen <dave@sr71.net>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Christoph Hellwig <hch@lst.de>,
Andrew Morton <akpm@linux-foundation.org>,
Dan Williams <dan.j.williams@intel.com>,
khandual@linux.vnet.ibm.com, vbabka@suse.cz, linux-mm@kvack.org,
Linux-Arch <linux-arch@vger.kernel.org>
Subject: Re: [PATCH] proc: mm: export PTE sizes directly in smaps (v3)
Date: Fri, 9 Dec 2016 15:10:05 -0800 [thread overview]
Message-ID: <1103bf7b-b4a9-3378-7f09-ea67f8bed4a8@sr71.net> (raw)
Message-ID: <20161209231005.2lA_8NZT9x3tdZpBg7ItsFkPtcCjAFRRIAZM9LJd1nI@z> (raw)
In-Reply-To: <CAHp75Vee5EzoxOoXot0+0jRKtX+nhj+obJp-zR3Kp3osdKCVNA@mail.gmail.com>
On 12/01/2016 06:50 AM, Andy Shevchenko wrote:
>> > +static int size_shift(unsigned long long nr)
>> > +{
>> > + if (nr < (1ULL<<10))
>> > + return 0;
>> > + if (nr < (1ULL<<20))
>> > + return 10;
>> > + if (nr < (1ULL<<30))
>> > + return 20;
>> > + if (nr < (1ULL<<40))
>> > + return 30;
>> > + if (nr < (1ULL<<50))
>> > + return 40;
>> > + if (nr < (1ULL<<60))
>> > + return 50;
>> > + return 60;
>> > +}
>> > +
> New copy of string_get_size() ?
Not really. That prints to a buffer, so we'll need to allocate stack
space for a buffer, which we also have to size properly. We also want
to be consistent with other parts of smaps that mean kB==1024 bytes, so
we want string_get_size()'s STRING_UNITS_10 strings, but
STRING_UNITS_2's divisor.
Also, guaranteeing that we have a power-of-2 'block size' lets us cheat
and do things much faster than using real division. Not that it
matters, but we could do it thousands of times for a large smaps file.
Being defined locally, this stuff also gets inlined pretty aggressively.
Given all that, I'm not sure I want to modify string_get_size() to do
exactly what we need here.
next prev parent reply other threads:[~2016-12-09 23:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-29 20:17 [PATCH] proc: mm: export PTE sizes directly in smaps (v3) Dave Hansen
2016-12-01 12:21 ` Vlastimil Babka
2016-12-01 14:50 ` Andy Shevchenko
2016-12-09 23:10 ` Dave Hansen [this message]
2016-12-09 23:10 ` Dave Hansen
2016-12-02 15:43 ` Aneesh Kumar K.V
2016-12-02 15:43 ` Aneesh Kumar K.V
2016-12-02 16:14 ` Aneesh Kumar K.V
2016-12-02 16:14 ` Aneesh Kumar K.V
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=1103bf7b-b4a9-3378-7f09-ea67f8bed4a8@sr71.net \
--to=dave@sr71.net \
--cc=akpm@linux-foundation.org \
--cc=andy.shevchenko@gmail.com \
--cc=dan.j.williams@intel.com \
--cc=hch@lst.de \
--cc=khandual@linux.vnet.ibm.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vbabka@suse.cz \
/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).