Re: [PATCH net-next 6/7] xsk: add helper to get &xdp_desc's DMA and meta pointer in one go

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

 



On Fri, 20 Dec 2024 16:58:57 +0100 Alexander Lobakin wrote:
> > On Wed, 18 Dec 2024 18:44:34 +0100 Alexander Lobakin wrote:  
> >> +	ret = (typeof(ret)){
> >> +		/* Same logic as in xp_raw_get_dma() */
> >> +		.dma	= (pool->dma_pages[addr >> PAGE_SHIFT] &
> >> +			   ~XSK_NEXT_PG_CONTIG_MASK) + (addr & ~PAGE_MASK),
> >> +	};  
> > 
> > This is quite ugly IMHO  
> 
> What exactly: that the logic is copied or how that code (>> & ~ + & ~)
> looks like?
> 
> If the former, I already thought of making a couple internal defs to
> avoid copying.
> If the latter, I also thought of this, just wanted to be clear that it's
> the same as in xp_raw_get_dma(). But it can be refactored to look more
> fancy anyway.
> 
> Or the compound return looks ugly? Or the struct initialization?

Compound using typeof() and the fact it's multi line.

It's a two member struct, which you return by value,
so unlikely to grow. Why not init the members manually?

And you could save the intermediate computations to a temp variable
(addr >> PAGE_SHIFT, addr & ~PAGE_MASK) to make the line shorter.




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux