Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1539729

Re: [PATCH] proc: mm: export PTE sizes directly in smaps (v3)

From Dave Hansen <dave@sr71.net>
Newsgroups linux.kernel
Subject Re: [PATCH] proc: mm: export PTE sizes directly in smaps (v3)
Date 2016-12-10 00:20 +0100
Message-ID <sMCCl-XS-11@gated-at.bofh.it> (permalink)
References <sIX2G-4Lk-13@gated-at.bofh.it> <sJB06-5a9-31@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] proc: mm: export PTE sizes directly in smaps (v3) Dave Hansen <dave@sr71.net> - 2016-11-29 21:20 +0100
  Re: [PATCH] proc: mm: export PTE sizes directly in smaps (v3) Vlastimil Babka <vbabka@suse.cz> - 2016-12-01 13:30 +0100
  Re: [PATCH] proc: mm: export PTE sizes directly in smaps (v3) Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-12-01 16:00 +0100
    Re: [PATCH] proc: mm: export PTE sizes directly in smaps (v3) Dave Hansen <dave@sr71.net> - 2016-12-10 00:20 +0100
  Re: [PATCH] proc: mm: export PTE sizes directly in smaps (v3) "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> - 2016-12-02 16:50 +0100
  Re: [PATCH] proc: mm: export PTE sizes directly in smaps (v3) "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> - 2016-12-02 19:10 +0100

csiph-web