From: Yury Norov <yury.norov@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Mateusz Guzik <mjguzik@gmail.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
tglx@linutronix.de, rppt@kernel.org
Subject: Re: [PATCH v2 2/2] mm,nodemask: Use nr_node_ids
Date: Thu, 3 Aug 2023 14:00:26 -0700 [thread overview]
Message-ID: <ZMwVanb0nTbOiWyn@yury-ThinkPad> (raw)
In-Reply-To: <ZMwRBqTgkvA7o9x3@yury-ThinkPad>
> Consider MAX_NUMNODES == 64 and nr_node_ids == 4. Then
> small_nodemask_bits == 64.
>
> The nodes_full() will set all 64 bits:
>
> #define nodes_full(nodemask) __nodes_full(&(nodemask), small_nodemask_bits)
> static inline bool __nodes_full(const nodemask_t *srcp, unsigned int nbits)
> {
> return bitmap_full(srcp->bits, nbits);
> }
Damn, copied the wrong function. This should be nodes_setall() of
course:
#define nodes_setall(dst) __nodes_setall(&(dst), large_nodemask_bits)
static inline void __nodes_setall(nodemask_t *dstp, unsigned int nbits)
{
bitmap_fill(dstp->bits, nbits);
}
> And the following nodes_weight() will return 64:
>
> #define nodes_weight(nodemask) __nodes_weight(&(nodemask), small_nodemask_bits)
> static inline int __nodes_weight(const nodemask_t *srcp, unsigned int nbits)
> {
> return bitmap_weight(srcp->bits, nbits);
> }
>
> Which is definitely wrong because there's 4 nodes at max. To solve
> this problem, both cpumask and nodemask implementations share the same
> rule: all bits beyond nr_{node,cpumask}_bits must be always cleared.
>
> See how cpumask_setall() implements that:
>
> static inline void cpumask_setall(struct cpumask *dstp)
> {
> // Make sure we don't break the optimization
> if (small_const_nbits(small_cpumask_bits)) {
> cpumask_bits(dstp)[0] = BITMAP_LAST_WORD_MASK(nr_cpumask_bits);
> return;
> }
>
> // Pass the exact (runtime) number of bits
> bitmap_fill(cpumask_bits(dstp), nr_cpumask_bits);
> }
>
> Hope that makes sense.
>
> Thanks,
> Yury
next prev parent reply other threads:[~2023-08-03 21:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 11:24 [PATCH 0/2] nodemask: " Peter Zijlstra
2023-08-02 11:24 ` [PATCH 1/2] mm: Mark nr_node_ids __ro_after_init Peter Zijlstra
2023-08-02 14:58 ` Mike Rapoport
2023-08-02 11:25 ` [PATCH 2/2] mm,nodemask: Use nr_node_ids Peter Zijlstra
2023-08-02 15:32 ` Mike Rapoport
2023-08-02 15:48 ` Peter Zijlstra
2023-08-02 19:36 ` [PATCH v2 " Peter Zijlstra
2023-08-03 0:45 ` Yury Norov
2023-08-03 8:41 ` Peter Zijlstra
2023-08-03 20:41 ` Yury Norov
2023-08-03 21:00 ` Yury Norov [this message]
2023-08-04 8:14 ` Peter Zijlstra
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=ZMwVanb0nTbOiWyn@yury-ThinkPad \
--to=yury.norov@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mjguzik@gmail.com \
--cc=peterz@infradead.org \
--cc=rppt@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox