All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Leon Romanovsky <leon@kernel.org>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH] RDMA/restrack: Reorder fields in 'struct rdma_restrack_entry'
Date: Tue, 14 Feb 2023 11:01:00 -0400	[thread overview]
Message-ID: <Y+uiLCB7H2xVvQZW@ziepe.ca> (raw)
In-Reply-To: <75480cf9-8d06-7a7d-4624-6ddbb7d6053a@wanadoo.fr>

On Tue, Feb 14, 2023 at 03:34:21PM +0100, Christophe JAILLET wrote:
> Le 14/02/2023 à 14:08, Jason Gunthorpe a écrit :
> > On Tue, Feb 14, 2023 at 01:53:52PM +0100, Christophe JAILLET wrote:
> > > diff --git a/include/rdma/restrack.h b/include/rdma/restrack.h
> > > index 8b7c46daeb07..da53fefe6f9e 100644
> > > --- a/include/rdma/restrack.h
> > > +++ b/include/rdma/restrack.h
> > > @@ -80,6 +80,10 @@ struct rdma_restrack_entry {
> > >   	 * query stage.
> > >   	 */
> > >   	u8			no_track : 1;
> > > +	/**
> > > +	 * @user: user resource
> > > +	 */
> > > +	bool			user;
> > 
> > Can we combine this into the bitfield above?
> > 
> > Jason
> > 
> Hi,
> 
> and even above, we have
> 	bool	valid;
> 
> I wanted to keep the changes as minimal as possible, but I can change them
> all in a single bitfield.

IIRC it needs to be checked, I vaugely remember valid can't be a
bitfield because it is an atomic
> Do you want code such as:
> static void rdma_restrack_attach_task(struct rdma_restrack_entry *res,
> 				      struct task_struct *task)
> {
> 	if (WARN_ON_ONCE(!task))
> 		return;
> 
> 	if (res->task)
> 		put_task_struct(res->task);
> 	get_task_struct(task);
> 	res->task = task;
> 	res->user = true;			<--------
> }
>
> to be changed with 0/1 instead of false/true?

I'd keep with true/false

Ideally the bitfield itself would be bool type too

> Apparently gcc 11.3 is fine with using true with u8:1, but I don't find it
> really logical.

Bool types can be casted to integers in defined ways, it is pretty
normal.

Jason

  reply	other threads:[~2023-02-14 15:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14 12:53 [PATCH] RDMA/restrack: Reorder fields in 'struct rdma_restrack_entry' Christophe JAILLET
2023-02-14 13:08 ` Jason Gunthorpe
2023-02-14 14:34   ` Christophe JAILLET
2023-02-14 15:01     ` Jason Gunthorpe [this message]
2023-02-15 11:31       ` Leon Romanovsky
2023-02-20 22:16         ` Christophe JAILLET

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=Y+uiLCB7H2xVvQZW@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.