From: Andrew Morton <akpm@linux-foundation.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Manfred Spraul <manfred@colorfullife.com>,
Davidlohr Bueso <dave@stgolabs.net>
Subject: Re: [PATCH] ipc: Convert ipcs_idr to XArray
Date: Sat, 18 Apr 2020 15:08:40 -0700 [thread overview]
Message-ID: <20200418150840.5fd3916821a49993b0ff78e4@linux-foundation.org> (raw)
In-Reply-To: <20200418213451.GS5820@bombadil.infradead.org>
On Sat, 18 Apr 2020 14:34:51 -0700 Matthew Wilcox <willy@infradead.org> wrote:
> On Sat, Apr 18, 2020 at 01:15:09PM -0700, Andrew Morton wrote:
> > > --- a/ipc/util.c
> > > +++ b/ipc/util.c
> > > @@ -104,12 +104,20 @@ static const struct rhashtable_params ipc_kht_params = {
> > > .automatic_shrinking = true,
> > > };
> > >
> > > +#ifdef CONFIG_CHECKPOINT_RESTORE
> >
> > The code grew a few additional CONFIG_CHECKPOINT_RESTORE ifdefs.
> > What's going on here? Why is CRIU special in ipc/?
>
> "grew a few"? I added (this) one and deleted two others. From in the
> middle of functions, like we usually prefer.
>
Oh.
>
> @@ -17,11 +17,11 @@ struct ipc_ids {
> ...
> #ifdef CONFIG_CHECKPOINT_RESTORE
> - int next_id;
> + int restore_id;
> #endif
>
> > > +#define set_restore_id(ids, x) ids->restore_id = x
> > > +#define get_restore_id(ids) ids->restore_id
> > > +#else
> > > +#define set_restore_id(ids, x) do { } while (0)
> > > +#define get_restore_id(ids) (-1)
> > > +#endif
> >
> > Well these are ugly. Can't all this be done in C?
>
> Would you rather see it done as:
>
> static inline void set_restore_id(struct ipc_ids *ids, int id)
> {
> #ifdef CONFIG_CHECKPOINT_RESTORE
> ids->restore_id = id;
> #endif
> }
>
> static inline int get_restore_id(struct ipc_ids *ids)
> {
> #ifdef CONFIG_CHECKPOINT_RESTORE
> return ids->restore_id;
> #else
> return -1;
> #endif
> }
Looks nicer. Has type checking regardless of Kconfig. Doesn't have
lval-and-rval in one case, neither in the other. Doesn't risk
unused-var warnings dependent on Kconfig. Etc.
Could also do
#ifdef CONFIG_CHECKPOINT_RESTORE
static inline void set_restore_id(struct ipc_ids *ids, int id)
{
ids->restore_id = id;
}
static inline int get_restore_id(struct ipc_ids *ids)
{
return ids->restore_id;
return -1;
}
#else
...
next prev parent reply other threads:[~2020-04-18 22:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-26 15:14 [PATCH] ipc: Convert ipcs_idr to XArray Matthew Wilcox
2020-04-18 20:15 ` Andrew Morton
2020-04-18 21:34 ` Matthew Wilcox
2020-04-18 22:08 ` Andrew Morton [this message]
2020-04-20 15:35 ` Manfred Spraul
2020-04-20 17:06 ` Matthew Wilcox
2020-04-21 18:33 ` Matthew Wilcox
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=20200418150840.5fd3916821a49993b0ff78e4@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=dave@stgolabs.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--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).