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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YJ5ekZAddvWI3Hzk@hirez.programming.kicks-ass.net>
Date:   Fri, 14 May 2021 13:27:13 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Liam Howlett <liam.howlett@...cle.com>
Cc:     "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Song Liu <songliubraving@...com>,
        Davidlohr Bueso <dave@...olabs.net>,
        "Paul E . McKenney" <paulmck@...nel.org>,
        Matthew Wilcox <willy@...radead.org>,
        Laurent Dufour <ldufour@...ux.ibm.com>,
        David Rientjes <rientjes@...gle.com>,
        Axel Rasmussen <axelrasmussen@...gle.com>,
        Suren Baghdasaryan <surenb@...gle.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Rik van Riel <riel@...riel.com>,
        Michel Lespinasse <walken.cr@...il.com>
Subject: Re: [PATCH 26/94] Maple Tree: Add new data structure

On Fri, May 14, 2021 at 01:13:51PM +0200, Peter Zijlstra wrote:
> On Wed, Apr 28, 2021 at 03:36:02PM +0000, Liam Howlett wrote:

> > +static inline struct maple_node *mte_to_node(const struct maple_enode *entry)
> > +{
> > +	return (struct maple_node *)((unsigned long)entry & ~127);
> > +}
> 
> > +static inline struct maple_topiary *mte_to_mat(const struct maple_enode *entry)
> > +{
> > +	return (struct maple_topiary *)((unsigned long)entry & ~127);
> > +}
> 
> Can we please write masks as hex, also do they want a pretty name?
> 
> 
> This has more magic mask values, proper names might be good:
> 
> > +static inline void mte_set_parent(struct maple_enode *enode,
> > +				 const struct maple_enode *parent,
> > +				 unsigned char slot)
> > +{
> > +	unsigned long bitmask = 0x78;
> > +	unsigned long val = (unsigned long) parent;
> > +	unsigned long type = 0;
> > +
> > +	switch (mte_node_type(parent)) {
> > +	case maple_range_64:
> > +	case maple_arange_64:
> > +		type = 6;
> > +		break;
> > +	default:
> > +		break;
> > +	}
> > +
> > +	val &= ~bitmask; // Remove any old slot number.
> > +	val |= (slot << MAPLE_PARENT_SHIFT); // Set the slot.
> > +	val |= type;
> > +	mte_to_node(enode)->parent = ma_parent_ptr(val);
> > +}
> 
> > +static inline unsigned int mte_parent_slot(const struct maple_enode *enode)
> > +{
> > +	unsigned long bitmask = 0x7C;
> > +	unsigned long val = (unsigned long) mte_to_node(enode)->parent;
> > +
> > +	if (val & 1)
> > +		return 0; // Root.
> > +
> > +	return (val & bitmask) >> MAPLE_PARENT_SHIFT;
> 
> 7c is 1111100, but then you're shifting out the one bit that makes the
> difference from the above magic 0x78. What gives?

IMO the more obvious way is something like:

	(val >> MAPLE_PARENT_SHIFT) & ((1 << MAPLE_SLOT_BITS)-1);

And then we also see that 3+4 gives 7, which is that magical 127 above,
are them the same? Related names would be good in that case.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ