lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <28af573f-2718-4d09-9dbd-0bb5764dc794@intel.com>
Date: Mon, 23 Dec 2024 14:50:54 +0100
From: Alexander Lobakin <aleksander.lobakin@...el.com>
To: Jakub Kicinski <kuba@...nel.org>
CC: Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller"
	<davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Paolo Abeni
	<pabeni@...hat.com>, Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann
	<daniel@...earbox.net>, John Fastabend <john.fastabend@...il.com>, "Andrii
 Nakryiko" <andrii@...nel.org>, "Jose E. Marchesi" <jose.marchesi@...cle.com>,
	Toke Høiland-Jørgensen <toke@...hat.com>, "Magnus
 Karlsson" <magnus.karlsson@...el.com>, Maciej Fijalkowski
	<maciej.fijalkowski@...el.com>, Przemek Kitszel
	<przemyslaw.kitszel@...el.com>, Jason Baron <jbaron@...mai.com>, "Casey
 Schaufler" <casey@...aufler-ca.com>, Nathan Chancellor <nathan@...nel.org>,
	<bpf@...r.kernel.org>, <netdev@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next 6/7] xsk: add helper to get &xdp_desc's DMA and
 meta pointer in one go

From: Jakub Kicinski <kuba@...nel.org>
Date: Fri, 20 Dec 2024 09:26:47 -0800

> 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?

BTW sometimes such compound initializations are faster than
member-by-member assignment. *Not* in this case, however, so sure,
done already.

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

I'll just derive it into a oneliner to not copy the same stuff again
between functions; also, page helpers like PHYS_PFN() and
offset_in_page() can be used here instead of open-coding.

Merry holidays!
Olek

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ