From: Matthew Wilcox <willy@infradead.org>
To: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
maple-tree@lists.infradead.org, akpm@linux-foundation.org,
liam.howlett@oracle.com, zhangpeng.00@bytedance.com
Subject: Re: [PATCH] maple_tree: do not preallocate nodes for slot stores
Date: Tue, 12 Dec 2023 20:57:48 +0000 [thread overview]
Message-ID: <ZXjJTM0pDksnslgo@casper.infradead.org> (raw)
In-Reply-To: <20231212194640.217966-1-sidhartha.kumar@oracle.com>
On Tue, Dec 12, 2023 at 11:46:40AM -0800, Sidhartha Kumar wrote:
> + /* Slot store, does not require additional nodes */
> + if ((node_size == mas->end) && ((!mt_in_rcu(mas->tree))
> + || (wr_mas.offset_end - mas->offset == 1)))
> + return 0;
Should we refactor this into a mas_is_slot_store() predicate?
A few coding-style problems with it as it's currently written:
1. The indentation on the second line is wrong. It makes the
continuation of the condition look like part of the statement. Use
extra whitespace to indent. eg:
if ((node_size == mas->end) && ((!mt_in_rcu(mas->tree))
|| (wr_mas.offset_end - mas->offset == 1)))
return 0;
2. The operator goes last on the line, not at the beginning of the
continuation line. ie:
if ((node_size == mas->end) && ((!mt_in_rcu(mas->tree)) ||
(wr_mas.offset_end - mas->offset == 1)))
return 0;
3. You don't need parens around the !mt_in_rcu(mas->tree). There's
no ambiguity to solve here:
if ((node_size == mas->end) && (!mt_in_rcu(mas->tree) ||
(wr_mas.offset_end - mas->offset == 1)))
return 0;
But I'd write it as:
if ((node_size == mas->end) &&
(!mt_in_rcu(mas->tree) || (wr_mas.offset_end - mas->offset == 1)))
return 0;
because then the whitespace matches how you're supposed to parse the
condition, and so the next person to read this code will have an easier
time of it.
next prev parent reply other threads:[~2023-12-12 20:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 19:46 Sidhartha Kumar
2023-12-12 20:27 ` Liam R. Howlett
2023-12-12 20:57 ` Matthew Wilcox [this message]
2023-12-12 21:41 ` Liam R. Howlett
2023-12-12 21:48 ` Sidhartha Kumar
2023-12-13 1:00 ` Andrew Morton
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=ZXjJTM0pDksnslgo@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=liam.howlett@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
--cc=sidhartha.kumar@oracle.com \
--cc=zhangpeng.00@bytedance.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