Re: [PATCH] RDMA/restrack: Reorder fields in 'struct rdma_restrack_entry'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux