From: Oleksandr Natalenko <oleksandr@natalenko.name>
To: Michal Hocko <mhocko@suse.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>,
Matthew Wilcox <willy@infradead.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Miaohe Lin <linmiaohe@huawei.com>,
Mel Gorman <mgorman@techsingularity.net>,
Stephen Rothwell <sfr@canb.auug.org.au>
Subject: Re: [RFC PATCH 1/1] mm: provide one common K(x) macro
Date: Wed, 01 Sep 2021 12:50:40 +0200 [thread overview]
Message-ID: <5529272.KFOknHQvy8@natalenko.name> (raw)
In-Reply-To: <YS9WiF6enhSo8sYc@dhcp22.suse.cz>
Hello.
On středa 1. září 2021 12:31:36 CEST Michal Hocko wrote:
> On Wed 01-09-21 11:21:49, Oleksandr Natalenko wrote:
> > There are various places where the K(x) macro is defined. This commit
> > gets rid of multiple definitions and provides a common one.
> >
> > This doesn't solve open-coding this macro in various other places. This
> > should be addressed by another subsequent commit.
>
> Why is this an improvement? You are adding a header file for a single
> macro which sounds like an overkill.
I agree a separate header file is an overkill for just one #define, hence
still looking for a suggestion on a better place for it.
> The overall net outcome is added
> lines of code.
Not always. There are some long statements like:
```
seq_printf(seq, ",size=%luk",
sbinfo->max_blocks << (PAGE_SHIFT - 10));
```
that are split into two lines. With the macro those take one line only:
```
seq_printf(seq, ",size=%luk", K(sbinfo->max_blocks));
```
As of now (counting unposted open-coding replacements) the grand total is:
```
31 files changed, 104 insertions(+), 90 deletions(-)
```
which is not that horrible.
> It is not like K() or any of its variant is adding a
> maintenance burden due to code duplication. So why do we want to change
> the existing state?
For me it's about readability. Compare, for instance:
```
seq_put_decimal_ull_width(m, str, (val) << (PAGE_SHIFT-10), 8)
```
and
```
seq_put_decimal_ull_width(m, str, K(val), 8)
```
It's a small yet visible difference.
Thanks.
--
Oleksandr Natalenko (post-factum)
next prev parent reply other threads:[~2021-09-01 10:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-01 9:21 [RFC PATCH 0/1] mm: provide one common K(x) macro Oleksandr Natalenko
2021-09-01 9:21 ` [RFC PATCH 1/1] " Oleksandr Natalenko
2021-09-01 10:31 ` Michal Hocko
2021-09-01 10:50 ` Oleksandr Natalenko [this message]
2021-09-01 11:11 ` Michal Hocko
2021-09-02 14:52 ` David Laight
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=5529272.KFOknHQvy8@natalenko.name \
--to=oleksandr@natalenko.name \
--cc=akpm@linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@suse.com \
--cc=sfr@canb.auug.org.au \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/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).