* Re: linux-next: manual merge of the audit tree with the powerpc tree
From: Christophe Leroy @ 2021-12-17 14:11 UTC (permalink / raw)
To: Paul Moore
Cc: Stephen Rothwell, Richard Guy Briggs, Linux Kernel Mailing List,
Linux Next Mailing List, Cédric Le Goater, PowerPC
In-Reply-To: <CAHC9VhTcV6jn4z7uGXZb=RZ5k7W4KW1vnoAUMHN6Zhkxsw1Xpg@mail.gmail.com>
Le 17/12/2021 à 00:04, Paul Moore a écrit :
> On Thu, Dec 16, 2021 at 4:08 AM Christophe Leroy
> <christophe.leroy@csgroup.eu> wrote:
>> Thanks Cédric, I've now been able to install debian PPC32 port of DEBIAN
>> 11 on QEMU and run the tests.
>>
>> I followed instructions in file README.md provided in the test suite.
>> I also modified tests/Makefile to force MODE := 32
>>
>> I've got a lot of failures, am I missing some options in the kernel or
>> something ?
>>
>> Running as user root
>> with context root:::
>> on system
>
> While SELinux is not required for audit, I don't think I've ever run
> it on system without SELinux. In theory the audit-testsuite shouldn't
> rely on SELinux being present (other than the SELinux specific tests
> of course), but I'm not confident enough to say that the test suite
> will run without problem without SELinux.
>
> If it isn't too difficult, I would suggest enabling SELinux in your
> kernel build and ensuring the necessary userspace, policy, etc. is
> installed. You don't need to worry about getting it all running
> correctly; the audit-testsuite should pass with SELinux in permissive
> mode.
>
> If you're still seeing all these failures after trying that let us know.
>
Still the same it seems:
Running as user root
with context unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
on system
# Test 3 got: "256" (backlog_wait_time_actual_reset/test at line 151)
# Expected: "0"
# backlog_wait_time_actual_reset/test line 151 is: ok( $result, 0 );
# Was an event found?
# Test 4 got: "0" (backlog_wait_time_actual_reset/test at line 168)
# Expected: "1"
# backlog_wait_time_actual_reset/test line 168 is: ok( $found_msg, 1 );
# Was the message well-formed?
# Failed test 5 in backlog_wait_time_actual_reset/test at line 169
# backlog_wait_time_actual_reset/test line 169 is: ok( $reset_rc ==
$reset_msg )
backlog_wait_time_actual_reset/test ..
Failed 3/5 subtests
sh: 1: Syntax error: Bad fd number
sh: 1: Syntax error: Bad fd number
exec_execve/test ..................... ok
sh: 1: Syntax error: Bad fd number
sh: 1: Syntax error: Bad fd number
# Failed test 7 in exec_name/test at line 145 fail #4
# exec_name/test line 145 is: ok( $found[$_] == $expected[$_] );
sh: 1: Syntax error: Bad fd number
# Failed test 11 in exec_name/test at line 145 fail #7
sh: 1: Syntax error: Bad fd number
# Failed test 15 in exec_name/test at line 145 fail #10
# Failed test 17 in exec_name/test at line 145 fail #12
sh: 1: Syntax error: Bad fd number
# Failed test 19 in exec_name/test at line 145 fail #13
sh: 1: Syntax error: Bad fd number
# Failed test 23 in exec_name/test at line 145 fail #16
# Failed test 24 in exec_name/test at line 145 fail #17
sh: 1: Syntax error: Bad fd number
Error sending add rule data request (Rule exists)
# Failed test 29 in exec_name/test at line 145 fail #21
sh: 1: Syntax error: Bad fd number
exec_name/test .......................
Failed 8/29 subtests
sh: 1: Syntax error: Bad fd number
# Failed test 2 in file_create/test at line 121
# file_create/test line 121 is: ok($found_syscall);
# Failed test 3 in file_create/test at line 122
# file_create/test line 122 is: ok($found_parent);
# Failed test 4 in file_create/test at line 123
# file_create/test line 123 is: ok($found_create);
sh: 1: Syntax error: Bad fd number
file_create/test .....................
Failed 3/4 subtests
sh: 1: Syntax error: Bad fd number
# Failed test 2 in file_delete/test at line 122
# file_delete/test line 122 is: ok($found_syscall);
# Failed test 3 in file_delete/test at line 123
# file_delete/test line 123 is: ok($found_parent);
# Failed test 4 in file_delete/test at line 124
# file_delete/test line 124 is: ok($found_delete);
sh: 1: Syntax error: Bad fd number
file_delete/test .....................
Failed 3/4 subtests
sh: 1: Syntax error: Bad fd number
# Failed test 2 in file_rename/test at line 138
# file_rename/test line 138 is: ok($found_syscall);
# Test 3 got: "0" (file_rename/test at line 139)
# Expected: "2"
# file_rename/test line 139 is: ok( $found_parent, 2 );
# Failed test 4 in file_rename/test at line 140
# file_rename/test line 140 is: ok($found_create);
# Failed test 5 in file_rename/test at line 141
# file_rename/test line 141 is: ok($found_delete);
sh: 1: Syntax error: Bad fd number
file_rename/test .....................
Failed 4/5 subtests
sh: 1: Syntax error: Bad fd number
# Test 20 got: "256" (filter_exclude/test at line 167)
# Expected: "0"
# filter_exclude/test line 167 is: ok( $result, 0 );
# Test 21 got: "0" (filter_exclude/test at line 179)
# Expected: "1"
# filter_exclude/test line 179 is: ok( $found_msg, 1 );
sh: 1: Syntax error: Bad fd number
filter_exclude/test ..................
Failed 2/21 subtests
sh: 1: cannot create /dev/udp/127.0.0.1/24242: Directory nonexistent
# Test 3 got: "256" (filter_saddr_fam/test at line 88)
# Expected: "0"
# filter_saddr_fam/test line 88 is: ok( $result, 0 ); # Was an event
found?
# Test 4 got: "0" (filter_saddr_fam/test at line 129)
# Expected: "1"
# filter_saddr_fam/test line 129 is: ok( $found_msg, 1 ); # Was
the inet message found?
filter_saddr_fam/test ................
Failed 2/5 subtests
sh: 1: Syntax error: Bad fd number
sh: 1: Syntax error: Bad fd number
filter_sessionid/test ................ ok
sh: 1: Syntax error: Bad fd number
sh: 1: Syntax error: Bad fd number
login_tty/test ....................... ok
# Test 3 got: "256" (lost_reset/test at line 150)
# Expected: "0"
# lost_reset/test line 150 is: ok( $result, 0 ); # Was an event found?
# Test 4 got: "0" (lost_reset/test at line 167)
# Expected: "1"
# lost_reset/test line 167 is: ok( $found_msg, 1 ); # Was
the message well-formed?
# Failed test 5 in lost_reset/test at line 168
# lost_reset/test line 168 is: ok( $reset_rc == $reset_msg ); # Do
the two lost values agree?
lost_reset/test ......................
Failed 3/5 subtests
sh: 1: Syntax error: Bad fd number
sh: 1: cannot create /dev/udp/127.0.0.1/42424: Directory nonexistent
sh: 1: cannot create /dev/udp/::1/42424: Directory nonexistent
sh: 1: cannot create /dev/tcp/127.0.0.1/42424: Directory nonexistent
sh: 1: cannot create /dev/tcp/::1/42424: Directory nonexistent
# Failed test 4 in netfilter_pkt/test at line 144 fail #3
# netfilter_pkt/test line 144 is: ok( $found[$_] ); # Was the
nfmarked parcket found?
# Failed test 5 in netfilter_pkt/test at line 144 fail #4
# Failed test 6 in netfilter_pkt/test at line 144 fail #5
# Failed test 7 in netfilter_pkt/test at line 144 fail #6
# Failed test 10 in netfilter_pkt/test at line 148 fail #3
# netfilter_pkt/test line 148 is: ok( $fields[$_] == $fields );
# $_ Correct number of fields?
# Failed test 11 in netfilter_pkt/test at line 148 fail #4
# Failed test 12 in netfilter_pkt/test at line 148 fail #5
# Failed test 13 in netfilter_pkt/test at line 148 fail #6
sh: 1: Syntax error: Bad fd number
Christophe
^ permalink raw reply
* Re: [PATCH v3 11/12] lkdtm: Fix execute_[user]_location()
From: Helge Deller @ 2021-12-17 17:12 UTC (permalink / raw)
To: Christophe Leroy, Kees Cook, Michael Ellerman
Cc: linux-arch@vger.kernel.org, linux-ia64@vger.kernel.org,
Arnd Bergmann, linux-parisc@vger.kernel.org,
linux-kernel@vger.kernel.org, James E.J. Bottomley,
linux-mm@kvack.org, Paul Mackerras, Greg Kroah-Hartman,
Andrew Morton, linuxppc-dev@lists.ozlabs.org
In-Reply-To: <e7793192-6879-490d-1f37-3d6d6908a121@csgroup.eu>
On 12/17/21 12:49, Christophe Leroy wrote:
> Hi Kees,
>
> Le 17/10/2021 à 14:38, Christophe Leroy a écrit :
>> execute_location() and execute_user_location() intent
>> to copy do_nothing() text and execute it at a new location.
>> However, at the time being it doesn't copy do_nothing() function
>> but do_nothing() function descriptor which still points to the
>> original text. So at the end it still executes do_nothing() at
>> its original location allthough using a copied function descriptor.
>>
>> So, fix that by really copying do_nothing() text and build a new
>> function descriptor by copying do_nothing() function descriptor and
>> updating the target address with the new location.
>>
>> Also fix the displayed addresses by dereferencing do_nothing()
>> function descriptor.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>
> Do you have any comment to this patch and to patch 12 ?
>
> If not, is it ok to get your acked-by ?
Hi Christophe,
I think this whole series is a nice cleanup and harmonization
of how function descriptors are used.
At least for the PA-RISC parts you may add:
Acked-by: Helge Deller <deller@gmx.de>
Thanks!
Helge
>
>> ---
>> drivers/misc/lkdtm/perms.c | 37 ++++++++++++++++++++++++++++---------
>> 1 file changed, 28 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/misc/lkdtm/perms.c b/drivers/misc/lkdtm/perms.c
>> index 035fcca441f0..1cf24c4a79e9 100644
>> --- a/drivers/misc/lkdtm/perms.c
>> +++ b/drivers/misc/lkdtm/perms.c
>> @@ -44,19 +44,34 @@ static noinline void do_overwritten(void)
>> return;
>> }
>>
>> +static void *setup_function_descriptor(func_desc_t *fdesc, void *dst)
>> +{
>> + if (!have_function_descriptors())
>> + return dst;
>> +
>> + memcpy(fdesc, do_nothing, sizeof(*fdesc));
>> + fdesc->addr = (unsigned long)dst;
>> + barrier();
>> +
>> + return fdesc;
>> +}
>> +
>> static noinline void execute_location(void *dst, bool write)
>> {
>> - void (*func)(void) = dst;
>> + void (*func)(void);
>> + func_desc_t fdesc;
>> + void *do_nothing_text = dereference_function_descriptor(do_nothing);
>>
>> - pr_info("attempting ok execution at %px\n", do_nothing);
>> + pr_info("attempting ok execution at %px\n", do_nothing_text);
>> do_nothing();
>>
>> if (write == CODE_WRITE) {
>> - memcpy(dst, do_nothing, EXEC_SIZE);
>> + memcpy(dst, do_nothing_text, EXEC_SIZE);
>> flush_icache_range((unsigned long)dst,
>> (unsigned long)dst + EXEC_SIZE);
>> }
>> - pr_info("attempting bad execution at %px\n", func);
>> + pr_info("attempting bad execution at %px\n", dst);
>> + func = setup_function_descriptor(&fdesc, dst);
>> func();
>> pr_err("FAIL: func returned\n");
>> }
>> @@ -66,16 +81,19 @@ static void execute_user_location(void *dst)
>> int copied;
>>
>> /* Intentionally crossing kernel/user memory boundary. */
>> - void (*func)(void) = dst;
>> + void (*func)(void);
>> + func_desc_t fdesc;
>> + void *do_nothing_text = dereference_function_descriptor(do_nothing);
>>
>> - pr_info("attempting ok execution at %px\n", do_nothing);
>> + pr_info("attempting ok execution at %px\n", do_nothing_text);
>> do_nothing();
>>
>> - copied = access_process_vm(current, (unsigned long)dst, do_nothing,
>> + copied = access_process_vm(current, (unsigned long)dst, do_nothing_text,
>> EXEC_SIZE, FOLL_WRITE);
>> if (copied < EXEC_SIZE)
>> return;
>> - pr_info("attempting bad execution at %px\n", func);
>> + pr_info("attempting bad execution at %px\n", dst);
>> + func = setup_function_descriptor(&fdesc, dst);
>> func();
>> pr_err("FAIL: func returned\n");
>> }
>> @@ -153,7 +171,8 @@ void lkdtm_EXEC_VMALLOC(void)
>>
>> void lkdtm_EXEC_RODATA(void)
>> {
>> - execute_location(lkdtm_rodata_do_nothing, CODE_AS_IS);
>> + execute_location(dereference_function_descriptor(lkdtm_rodata_do_nothing),
>> + CODE_AS_IS);
>> }
>>
>> void lkdtm_EXEC_USERSPACE(void)
^ permalink raw reply
* Re: [PATCH/RFC] mm: add and use batched version of __tlb_remove_table()
From: Dave Hansen @ 2021-12-17 18:26 UTC (permalink / raw)
To: Nikita Yushchenko, Will Deacon, Aneesh Kumar K.V, Andrew Morton,
Nick Piggin, Peter Zijlstra, Catalin Marinas, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, David S. Miller,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
Arnd Bergmann
Cc: linux-arch, linux-s390, x86, linux-kernel, linux-mm, kernel,
sparclinux, linuxppc-dev
In-Reply-To: <20211217081909.596413-1-nikita.yushchenko@virtuozzo.com>
On 12/17/21 12:19 AM, Nikita Yushchenko wrote:
> When batched page table freeing via struct mmu_table_batch is used, the
> final freeing in __tlb_remove_table_free() executes a loop, calling
> arch hook __tlb_remove_table() to free each table individually.
>
> Shift that loop down to archs. This allows archs to optimize it, by
> freeing multiple tables in a single release_pages() call. This is
> faster than individual put_page() calls, especially with memcg
> accounting enabled.
Could we quantify "faster"? There's a non-trivial amount of code being
added here and it would be nice to back it up with some cold-hard numbers.
> --- a/mm/mmu_gather.c
> +++ b/mm/mmu_gather.c
> @@ -95,11 +95,7 @@ bool __tlb_remove_page_size(struct mmu_gather *tlb, struct page *page, int page_
>
> static void __tlb_remove_table_free(struct mmu_table_batch *batch)
> {
> - int i;
> -
> - for (i = 0; i < batch->nr; i++)
> - __tlb_remove_table(batch->tables[i]);
> -
> + __tlb_remove_tables(batch->tables, batch->nr);
> free_page((unsigned long)batch);
> }
This leaves a single call-site for __tlb_remove_table():
> static void tlb_remove_table_one(void *table)
> {
> tlb_remove_table_sync_one();
> __tlb_remove_table(table);
> }
Is that worth it, or could it just be:
__tlb_remove_tables(&table, 1);
?
> -void free_pages_and_swap_cache(struct page **pages, int nr)
> +static void __free_pages_and_swap_cache(struct page **pages, int nr,
> + bool do_lru)
> {
> - struct page **pagep = pages;
> int i;
>
> - lru_add_drain();
> + if (do_lru)
> + lru_add_drain();
> for (i = 0; i < nr; i++)
> - free_swap_cache(pagep[i]);
> - release_pages(pagep, nr);
> + free_swap_cache(pages[i]);
> + release_pages(pages, nr);
> +}
> +
> +void free_pages_and_swap_cache(struct page **pages, int nr)
> +{
> + __free_pages_and_swap_cache(pages, nr, true);
> +}
> +
> +void free_pages_and_swap_cache_nolru(struct page **pages, int nr)
> +{
> + __free_pages_and_swap_cache(pages, nr, false);
> }
This went unmentioned in the changelog. But, it seems like there's a
specific optimization here. In the exiting code,
free_pages_and_swap_cache() is wasteful if no page in pages[] is on the
LRU. It doesn't need the lru_add_drain().
Any code that knows it is freeing all non-LRU pages can call
free_pages_and_swap_cache_nolru() which should perform better than
free_pages_and_swap_cache().
Should we add this to the for loop in __free_pages_and_swap_cache()?
for (i = 0; i < nr; i++) {
if (!do_lru)
VM_WARN_ON_ONCE_PAGE(PageLRU(pagep[i]),
pagep[i]);
free_swap_cache(...);
}
But, even more than that, do all the architectures even need the
free_swap_cache()? PageSwapCache() will always be false on x86, which
makes the loop kinda silly. x86 could, for instance, just do:
static inline void __tlb_remove_tables(void **tables, int nr)
{
release_pages((struct page **)tables, nr);
}
I _think_ this will work everywhere that has whole pages as page tables.
Taking that one step further, what if we only had one generic:
static inline void tlb_remove_tables(void **tables, int nr)
{
int i;
#ifdef ARCH_PAGE_TABLES_ARE_FULL_PAGE
release_pages((struct page **)tables, nr);
#else
arch_tlb_remove_tables(tables, i);
#endif
}
Architectures that set ARCH_PAGE_TABLES_ARE_FULL_PAGE (or whatever)
don't need to implement __tlb_remove_table() at all *and* can do
release_pages() directly.
This avoids all the confusion with the swap cache and LRU naming.
^ permalink raw reply
* Re: [PATCH/RFC] mm: add and use batched version of __tlb_remove_table()
From: Sam Ravnborg @ 2021-12-17 18:39 UTC (permalink / raw)
To: Nikita Yushchenko
Cc: Peter Zijlstra, Catalin Marinas, Dave Hansen, linux-mm,
sparclinux, Will Deacon, linux-arch, linux-s390, Vasily Gorbik,
Aneesh Kumar K.V, x86, Ingo Molnar, Christian Borntraeger,
Arnd Bergmann, Heiko Carstens, Nick Piggin, Borislav Petkov,
Thomas Gleixner, linux-kernel, kernel, Andrew Morton,
linuxppc-dev, David S. Miller
In-Reply-To: <20211217081909.596413-1-nikita.yushchenko@virtuozzo.com>
Hi Nikita,
How about adding the following to tlb.h:
#ifndef __tlb_remove_tables
static void __tlb_remove_tables(...)
{
....
}
#endif
And then the few archs that want to override __tlb_remove_tables
needs to do a
#define __tlb_remove_tables __tlb_remove_tables
static void __tlb_remove_tables(...)
{
...
}
In this way the archs that uses the default implementation needs not do
anything.
A few functions already uses this pattern in tlb.h - see for example tlb_start_vma
io.h is another file where you can see the same pattern.
Sam
^ permalink raw reply
* [PATCH] powerpc/mpic: Use bitmap_zalloc() when applicable
From: Christophe JAILLET @ 2021-12-17 21:54 UTC (permalink / raw)
To: mpe, benh, paulus, maz
Cc: kernel-janitors, Christophe JAILLET, linuxppc-dev, linux-kernel
'mpic->protected' is a bitmap. So use 'bitmap_zalloc()' to simplify
code and improve the semantic, instead of hand writing it.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
arch/powerpc/sysdev/mpic.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 995fb2ada507..626ba4a9f64f 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1323,8 +1323,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
psrc = of_get_property(mpic->node, "protected-sources", &psize);
if (psrc) {
/* Allocate a bitmap with one bit per interrupt */
- unsigned int mapsize = BITS_TO_LONGS(intvec_top + 1);
- mpic->protected = kcalloc(mapsize, sizeof(long), GFP_KERNEL);
+ mpic->protected = bitmap_zalloc(intvec_top + 1, GFP_KERNEL);
BUG_ON(mpic->protected == NULL);
for (i = 0; i < psize/sizeof(u32); i++) {
if (psrc[i] > intvec_top)
--
2.30.2
^ permalink raw reply related
* [PATCH] powerpc: dts: Remove "spidev" nodes
From: Rob Herring @ 2021-12-17 22:14 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras
Cc: devicetree, Mark Brown, linuxppc-dev, linux-kernel
"spidev" is not a real device, but a Linux implementation detail. It has
never been documented either. The kernel has WARNed on the use of it for
over 6 years. Time to remove its usage from the tree.
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
---
arch/powerpc/boot/dts/digsy_mtc.dts | 8 --------
arch/powerpc/boot/dts/o2d.dtsi | 6 ------
2 files changed, 14 deletions(-)
diff --git a/arch/powerpc/boot/dts/digsy_mtc.dts b/arch/powerpc/boot/dts/digsy_mtc.dts
index 57024a4c1e7d..dfaf974c0ce6 100644
--- a/arch/powerpc/boot/dts/digsy_mtc.dts
+++ b/arch/powerpc/boot/dts/digsy_mtc.dts
@@ -25,14 +25,6 @@ rtc@800 {
status = "disabled";
};
- spi@f00 {
- msp430@0 {
- compatible = "spidev";
- spi-max-frequency = <32000>;
- reg = <0>;
- };
- };
-
psc@2000 { // PSC1
status = "disabled";
};
diff --git a/arch/powerpc/boot/dts/o2d.dtsi b/arch/powerpc/boot/dts/o2d.dtsi
index b55a9e5bd828..7e52509fa506 100644
--- a/arch/powerpc/boot/dts/o2d.dtsi
+++ b/arch/powerpc/boot/dts/o2d.dtsi
@@ -34,12 +34,6 @@ psc@2000 { // PSC1
#address-cells = <1>;
#size-cells = <0>;
cell-index = <0>;
-
- spidev@0 {
- compatible = "spidev";
- spi-max-frequency = <250000>;
- reg = <0>;
- };
};
psc@2200 { // PSC2
--
2.32.0
^ permalink raw reply related
* Re: [patch V3 28/35] PCI/MSI: Simplify pci_irq_get_affinity()
From: Nathan Chancellor @ 2021-12-17 22:30 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Nishanth Menon, Mark Rutland, Stuart Yoder, Will Deacon,
Ashok Raj, Joerg Roedel, Jassi Brar, Sinan Kaya, iommu,
Peter Ujfalusi, Bjorn Helgaas, linux-arm-kernel, Jason Gunthorpe,
linux-pci, xen-devel, Kevin Tian, Arnd Bergmann, Robin Murphy,
Alex Williamson, Cedric Le Goater, Santosh Shilimkar,
Bjorn Helgaas, Megha Dey, Laurentiu Tudor, Juergen Gross,
Tero Kristo, Greg Kroah-Hartman, LKML, Vinod Koul, Marc Zygnier,
dmaengine, linuxppc-dev
In-Reply-To: <20211210221814.900929381@linutronix.de>
Hi Thomas,
On Fri, Dec 10, 2021 at 11:19:26PM +0100, Thomas Gleixner wrote:
> From: Thomas Gleixner <tglx@linutronix.de>
>
> Replace open coded MSI descriptor chasing and use the proper accessor
> functions instead.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Apologies if this has already been reported somewhere else or already
fixed, I did a search of all of lore and did not see anything similar to
it and I did not see any new commits in -tip around this.
I just bisected a boot failure on my AMD test desktop to this patch as
commit f48235900182 ("PCI/MSI: Simplify pci_irq_get_affinity()") in
-next. It looks like there is a problem with the NVMe drive after this
change according to the logs. Given that the hard drive is not getting
mounted for journald to write logs to, I am not really sure how to get
them from the machine so I have at least taken a picture of what I see
on my screen; open to ideas on that front!
https://github.com/nathanchance/bug-files/blob/0d25d78b5bc1d5e9c15192b3bc80676364de8287/f48235900182/crash.jpg
Please let me know what information I can provide to make debugging this
easier and I am more than happy to apply and test patches as needed.
Cheers,
Nathan
^ permalink raw reply
* Re: [PATCH/RFC] mm: add and use batched version of __tlb_remove_table()
From: Peter Zijlstra @ 2021-12-18 0:37 UTC (permalink / raw)
To: Nikita Yushchenko
Cc: Catalin Marinas, Dave Hansen, linux-mm, sparclinux, Will Deacon,
linux-arch, linux-s390, Vasily Gorbik, Aneesh Kumar K.V, x86,
Ingo Molnar, Christian Borntraeger, Arnd Bergmann, Heiko Carstens,
Nick Piggin, kernel, Thomas Gleixner, linux-kernel,
Borislav Petkov, Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20211217081909.596413-1-nikita.yushchenko@virtuozzo.com>
On Fri, Dec 17, 2021 at 11:19:10AM +0300, Nikita Yushchenko wrote:
> When batched page table freeing via struct mmu_table_batch is used, the
> final freeing in __tlb_remove_table_free() executes a loop, calling
> arch hook __tlb_remove_table() to free each table individually.
>
> Shift that loop down to archs. This allows archs to optimize it, by
> freeing multiple tables in a single release_pages() call. This is
> faster than individual put_page() calls, especially with memcg
> accounting enabled.
>
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> Signed-off-by: Nikita Yushchenko <nikita.yushchenko@virtuozzo.com>
> ---
> arch/arm/include/asm/tlb.h | 5 ++++
> arch/arm64/include/asm/tlb.h | 5 ++++
> arch/powerpc/include/asm/book3s/32/pgalloc.h | 8 +++++++
> arch/powerpc/include/asm/book3s/64/pgalloc.h | 1 +
> arch/powerpc/include/asm/nohash/pgalloc.h | 8 +++++++
> arch/powerpc/mm/book3s64/pgtable.c | 8 +++++++
> arch/s390/include/asm/tlb.h | 1 +
> arch/s390/mm/pgalloc.c | 8 +++++++
> arch/sparc/include/asm/pgalloc_64.h | 8 +++++++
> arch/x86/include/asm/tlb.h | 5 ++++
> include/asm-generic/tlb.h | 2 +-
> include/linux/swap.h | 5 +++-
> mm/mmu_gather.c | 6 +----
> mm/swap_state.c | 24 +++++++++++++++-----
> 14 files changed, 81 insertions(+), 13 deletions(-)
Oh gawd, that's terrible. Never, ever duplicate code like that.
I'm thinking the below does the same? But yes, please do as Dave said,
give us actual numbers that show this is worth it.
---
arch/Kconfig | 4 ++++
arch/arm/Kconfig | 1 +
arch/arm/include/asm/tlb.h | 5 -----
arch/arm64/Kconfig | 1 +
arch/arm64/include/asm/tlb.h | 5 -----
arch/x86/Kconfig | 1 +
arch/x86/include/asm/tlb.h | 4 ----
mm/mmu_gather.c | 22 +++++++++++++++++++---
8 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/arch/Kconfig b/arch/Kconfig
index 26b8ed11639d..f2bd3f5af2b1 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -415,6 +415,10 @@ config HAVE_ARCH_JUMP_LABEL_RELATIVE
config MMU_GATHER_TABLE_FREE
bool
+config MMU_GATHER_TABLE_PAGE
+ bool
+ depends on MMU_GATHER_TABLE_FREE
+
config MMU_GATHER_RCU_TABLE_FREE
bool
select MMU_GATHER_TABLE_FREE
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f0f9e8bec83a..11baaa5719c2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -110,6 +110,7 @@ config ARM
select HAVE_PERF_REGS
select HAVE_PERF_USER_STACK_DUMP
select MMU_GATHER_RCU_TABLE_FREE if SMP && ARM_LPAE
+ select MMU_GATHER_TABLE_PAGE if MMU
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_RSEQ
select HAVE_STACKPROTECTOR
diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/tlb.h
index b8cbe03ad260..9d9b21649ca0 100644
--- a/arch/arm/include/asm/tlb.h
+++ b/arch/arm/include/asm/tlb.h
@@ -29,11 +29,6 @@
#include <linux/swap.h>
#include <asm/tlbflush.h>
-static inline void __tlb_remove_table(void *_table)
-{
- free_page_and_swap_cache((struct page *)_table);
-}
-
#include <asm-generic/tlb.h>
static inline void
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index c4207cf9bb17..4aa28fb03f4f 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -196,6 +196,7 @@ config ARM64
select HAVE_FUNCTION_ARG_ACCESS_API
select HAVE_FUTEX_CMPXCHG if FUTEX
select MMU_GATHER_RCU_TABLE_FREE
+ select MMU_GATHER_TABLE_PAGE
select HAVE_RSEQ
select HAVE_STACKPROTECTOR
select HAVE_SYSCALL_TRACEPOINTS
diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h
index c995d1f4594f..401826260a5c 100644
--- a/arch/arm64/include/asm/tlb.h
+++ b/arch/arm64/include/asm/tlb.h
@@ -11,11 +11,6 @@
#include <linux/pagemap.h>
#include <linux/swap.h>
-static inline void __tlb_remove_table(void *_table)
-{
- free_page_and_swap_cache((struct page *)_table);
-}
-
#define tlb_flush tlb_flush
static void tlb_flush(struct mmu_gather *tlb);
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index b9281fab4e3e..a22e653f4d0e 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -235,6 +235,7 @@ config X86
select HAVE_PERF_REGS
select HAVE_PERF_USER_STACK_DUMP
select MMU_GATHER_RCU_TABLE_FREE if PARAVIRT
+ select MMU_GATHER_TABLE_PAGE
select HAVE_POSIX_CPU_TIMERS_TASK_WORK
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_RELIABLE_STACKTRACE if X86_64 && (UNWINDER_FRAME_POINTER || UNWINDER_ORC) && STACK_VALIDATION
diff --git a/arch/x86/include/asm/tlb.h b/arch/x86/include/asm/tlb.h
index 1bfe979bb9bc..dec5ffa3042a 100644
--- a/arch/x86/include/asm/tlb.h
+++ b/arch/x86/include/asm/tlb.h
@@ -32,9 +32,5 @@ static inline void tlb_flush(struct mmu_gather *tlb)
* below 'ifdef CONFIG_MMU_GATHER_RCU_TABLE_FREE' in include/asm-generic/tlb.h
* for more details.
*/
-static inline void __tlb_remove_table(void *table)
-{
- free_page_and_swap_cache(table);
-}
#endif /* _ASM_X86_TLB_H */
diff --git a/mm/mmu_gather.c b/mm/mmu_gather.c
index 1b9837419bf9..0195d0f13ed3 100644
--- a/mm/mmu_gather.c
+++ b/mm/mmu_gather.c
@@ -93,13 +93,29 @@ bool __tlb_remove_page_size(struct mmu_gather *tlb, struct page *page, int page_
#ifdef CONFIG_MMU_GATHER_TABLE_FREE
-static void __tlb_remove_table_free(struct mmu_table_batch *batch)
+#ifdef CONFIG_MMU_GATHER_TABLE_PAGE
+static inline void __tlb_remove_table(void *table)
+{
+ free_page_and_swap_cache(table);
+}
+
+static inline void __tlb_remove_tables(void **tables, int nr)
+{
+ free_pages_and_swap_cache_nolru((struct page **)tables, nr);
+}
+#else
+static inline void __tlb_remove_tables(void **tables, int nr)
{
int i;
- for (i = 0; i < batch->nr; i++)
- __tlb_remove_table(batch->tables[i]);
+ for (i = 0; i < nr; i++)
+ __tlb_remove_table(tables[i]);
+}
+#endif
+static void __tlb_remove_table_free(struct mmu_table_batch *batch)
+{
+ __tlb_remove_tables(batch->tables, batch->nr);
free_page((unsigned long)batch);
}
^ permalink raw reply related
* [PATCH] powerpc: use swap() to make code cleaner
From: davidcomponentone @ 2021-12-18 1:59 UTC (permalink / raw)
To: benh
Cc: Zeal Robot, davidcomponentone, linux-kernel, yang.guang5, paulus,
linuxppc-dev
From: Yang Guang <yang.guang5@zte.com.cn>
Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: David Yang <davidcomponentone@gmail.com>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
---
arch/powerpc/platforms/powermac/pic.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index 4921bccf0376..75d8d7ec53db 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -311,11 +311,8 @@ static void __init pmac_pic_probe_oldstyle(void)
/* Check ordering of master & slave */
if (of_device_is_compatible(master, "gatwick")) {
- struct device_node *tmp;
BUG_ON(slave == NULL);
- tmp = master;
- master = slave;
- slave = tmp;
+ swap(master, slave);
}
/* We found a slave */
--
2.30.2
^ permalink raw reply related
* [Bug 215217] Kernel fails to boot at an early stage when built with GCC_PLUGIN_LATENT_ENTROPY=y (PowerMac G4 3,6)
From: bugzilla-daemon @ 2021-12-18 2:19 UTC (permalink / raw)
To: linuxppc-dev
In-Reply-To: <bug-215217-206035@https.bugzilla.kernel.org/>
https://bugzilla.kernel.org/show_bug.cgi?id=215217
--- Comment #14 from Erhard F. (erhard_f@mailbox.org) ---
(In reply to Christophe Leroy from comment #13)
> arch/powerpc/lib/feature-fixups.o also need DISABLE_LATENT_ENTROPY_PLUGIN,
> see extract from you vmlinux below
I can confirm this works, thanks!
I need
arch/powerpc/kernel/Makefile:
CFLAGS_early_32.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
arch/powerpc/lib/Makefile:
CFLAGS_feature-fixups.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
to make it going on my G4 with GCC_PLUGIN_LATENT_ENTROPY=y. Modifying
setup_32.o is not needed.
--
You may reply to this email to add a comment.
You are receiving this mail because:
You are watching the assignee of the bug.
^ permalink raw reply
* [powerpc/merge] PMU: Kernel warning while running pmu/ebb selftests
From: Sachin Sant @ 2021-12-18 10:08 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Athira Rajeev, Madhavan Srinivasan
While running kernel selftests (lost_exception_test) against latest
powerpc merge/next branch code (5.16.0-rc5-03218-g798527287598)
following warning is seen:
[ 172.851380] ------------[ cut here ]------------
[ 172.851391] WARNING: CPU: 8 PID: 2901 at arch/powerpc/include/asm/hw_irq.h:246 power_pmu_disable+0x270/0x280
[ 172.851402] Modules linked in: dm_mod bonding nft_ct nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ip_set nf_tables rfkill nfnetlink sunrpc xfs libcrc32c pseries_rng xts vmx_crypto uio_pdrv_genirq uio sch_fq_codel ip_tables ext4 mbcache jbd2 sd_mod t10_pi sg ibmvscsi ibmveth scsi_transport_srp fuse
[ 172.851442] CPU: 8 PID: 2901 Comm: lost_exception_ Not tainted 5.16.0-rc5-03218-g798527287598 #2
[ 172.851451] NIP: c00000000013d600 LR: c00000000013d5a4 CTR: c00000000013b180
[ 172.851458] REGS: c000000017687860 TRAP: 0700 Not tainted (5.16.0-rc5-03218-g798527287598)
[ 172.851465] MSR: 8000000000029033 <SF,EE,ME,IR,DR,RI,LE> CR: 48004884 XER: 20040000
[ 172.851482] CFAR: c00000000013d5b4 IRQMASK: 1
[ 172.851482] GPR00: c00000000013d5a4 c000000017687b00 c000000002a10600 0000000000000004
[ 172.851482] GPR04: 0000000082004000 c0000008ba08f0a8 0000000000000000 00000008b7ed0000
[ 172.851482] GPR08: 00000000446194f6 0000000000008000 c00000000013b118 c000000000d58e68
[ 172.851482] GPR12: c00000000013d390 c00000001ec54a80 0000000000000000 0000000000000000
[ 172.851482] GPR16: 0000000000000000 0000000000000000 c000000015d5c708 c0000000025396d0
[ 172.851482] GPR20: 0000000000000000 0000000000000000 c00000000a3bbf40 0000000000000003
[ 172.851482] GPR24: 0000000000000000 c0000008ba097400 c0000000161e0d00 c00000000a3bb600
[ 172.851482] GPR28: c000000015d5c700 0000000000000001 0000000082384090 c0000008ba0020d8
[ 172.851549] NIP [c00000000013d600] power_pmu_disable+0x270/0x280
[ 172.851557] LR [c00000000013d5a4] power_pmu_disable+0x214/0x280
[ 172.851565] Call Trace:
[ 172.851568] [c000000017687b00] [c00000000013d5a4] power_pmu_disable+0x214/0x280 (unreliable)
[ 172.851579] [c000000017687b40] [c0000000003403ac] perf_pmu_disable+0x4c/0x60
[ 172.851588] [c000000017687b60] [c0000000003445e4] __perf_event_task_sched_out+0x1d4/0x660
[ 172.851596] [c000000017687c50] [c000000000d1175c] __schedule+0xbcc/0x12a0
[ 172.851602] [c000000017687d60] [c000000000d11ea8] schedule+0x78/0x140
[ 172.851608] [c000000017687d90] [c0000000001a8080] sys_sched_yield+0x20/0x40
[ 172.851615] [c000000017687db0] [c0000000000334dc] system_call_exception+0x18c/0x380
[ 172.851622] [c000000017687e10] [c00000000000c74c] system_call_common+0xec/0x268
[ 172.851629] --- interrupt: c00 at 0x7fffa9d0d2fc
[ 172.851633] NIP: 00007fffa9d0d2fc LR: 0000000010001914 CTR: 0000000000000000
[ 172.851638] REGS: c000000017687e80 TRAP: 0c00 Not tainted (5.16.0-rc5-03218-g798527287598)
[ 172.851643] MSR: 800000000280f033 <SF,VEC,VSX,EE,PR,FP,ME,IR,DR,RI,LE> CR: 28000288 XER: 00000000
[ 172.851657] IRQMASK: 0
[ 172.851657] GPR00: 000000000000009e 00007fffe44c0b40 00007fffa9e07300 0000000000000000
[ 172.851657] GPR04: 00007fffe44c0c28 0000000000000018 000000000000000a 0000000000000008
[ 172.851657] GPR08: 0000000000000007 0000000000000000 0000000000000000 0000000000000000
[ 172.851657] GPR12: 0000000000000000 00007fffa9eaa270 0000000000000000 0000000000000000
[ 172.851657] GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
[ 172.851657] GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
[ 172.851657] GPR24: 0000000000000190 0000000000000000 00000000000186a0 00000000000f423f
[ 172.851657] GPR28: 0000000010021650 0000000000000198 0000000010020238 000000000000d446
[ 172.851711] NIP [00007fffa9d0d2fc] 0x7fffa9d0d2fc
[ 172.851715] LR [0000000010001914] 0x10001914
[ 172.851719] --- interrupt: c00
[ 172.851722] Instruction dump:
[ 172.851725] 71490001 81280078 552905ac 79290020 2fa90000 4182fe9c 4bffff88 60000000
[ 172.851735] 4bee4729 60000000 9bdf0014 4bfffe00 <0fe00000> 60000000 60000000 60000000
[ 172.851745] ---[ end trace 10a1b687c9c436f7 ]—
CONFIG_PPC_IRQ_SOFT_MASK_DEBUG is enabled for this kernel.
The code in question was last changed by following commit:
commit 2c9ac51b850d
powerpc/perf: Fix PMU callbacks to clear pending PMI before resetting an overflown PMC
Reverting this commit helps.
Thanks
-Sachin
^ permalink raw reply
* Re: [patch V3 28/35] PCI/MSI: Simplify pci_irq_get_affinity()
From: Thomas Gleixner @ 2021-12-18 10:25 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Nishanth Menon, Mark Rutland, Stuart Yoder, Will Deacon,
Ashok Raj, Joerg Roedel, Jassi Brar, Sinan Kaya, iommu,
Peter Ujfalusi, Bjorn Helgaas, linux-arm-kernel, Jason Gunthorpe,
linux-pci, xen-devel, Kevin Tian, Arnd Bergmann, Robin Murphy,
Alex Williamson, Cedric Le Goater, Santosh Shilimkar,
Bjorn Helgaas, Megha Dey, Laurentiu Tudor, Juergen Gross,
Tero Kristo, Greg Kroah-Hartman, LKML, Vinod Koul, Marc Zygnier,
dmaengine, linuxppc-dev
In-Reply-To: <Yb0PaCyo/6z3XOlf@archlinux-ax161>
On Fri, Dec 17 2021 at 15:30, Nathan Chancellor wrote:
> On Fri, Dec 10, 2021 at 11:19:26PM +0100, Thomas Gleixner wrote:
> I just bisected a boot failure on my AMD test desktop to this patch as
> commit f48235900182 ("PCI/MSI: Simplify pci_irq_get_affinity()") in
> -next. It looks like there is a problem with the NVMe drive after this
> change according to the logs. Given that the hard drive is not getting
> mounted for journald to write logs to, I am not really sure how to get
> them from the machine so I have at least taken a picture of what I see
> on my screen; open to ideas on that front!
Bah. Fix below.
Thanks,
tglx
---
diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index 71802410e2ab..9b4910befeda 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -1100,7 +1100,7 @@ EXPORT_SYMBOL(pci_irq_vector);
*/
const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)
{
- int irq = pci_irq_vector(dev, nr);
+ int idx, irq = pci_irq_vector(dev, nr);
struct msi_desc *desc;
if (WARN_ON_ONCE(irq <= 0))
@@ -1113,7 +1113,10 @@ const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)
if (WARN_ON_ONCE(!desc->affinity))
return NULL;
- return &desc->affinity[nr].mask;
+
+ /* MSI has a mask array in the descriptor. */
+ idx = dev->msi_enabled ? nr : 0;
+ return &desc->affinity[idx].mask;
}
EXPORT_SYMBOL(pci_irq_get_affinity);
^ permalink raw reply related
* Re: [PATCH/RFC] mm: add and use batched version of __tlb_remove_table()
From: Nikita Yushchenko @ 2021-12-18 13:35 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Catalin Marinas, Dave Hansen, linux-mm, sparclinux, Will Deacon,
linux-arch, linux-s390, Vasily Gorbik, Aneesh Kumar K.V, x86,
Ingo Molnar, Christian Borntraeger, Arnd Bergmann, Heiko Carstens,
Nick Piggin, kernel, Thomas Gleixner, linux-kernel,
Borislav Petkov, Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20211218003742.GL16608@worktop.programming.kicks-ass.net>
> Oh gawd, that's terrible. Never, ever duplicate code like that.
What the patch does is:
- formally shift the loop one level down in the call graph, adding instances of __tmp_remove_tables()
exactly to locations where instances of __tmp_remove_table() already exist,
- on architectures where __tmp_remove_tables() resulted into calling free_page_and_swap_cache() in loop,
call batched free_page_and_swap_cache_nolru() instead,
- on other places, keep the loop as is - perhaps as a possible target for future optimizations.
The extra duplication added by this patch just highlights already existing duplication of
__tlb_remove_table() implementations.
Ok let's follow your suggestion instead. AFAIU, that is:
- remove the free_page_and_swap_cache() based implementation from archs,
- instead, add it into mm/mmu_gather.c, ifdef-ed by a new Kconfig key, and define that Kconfig key into
the archs that use it,
- then, keep the optimization inside mm/mmu_gather.c.
Indeed, the overall change will become smaller then. Thanks for the idea. Will post patches doing that soon.
Nikita
^ permalink raw reply
* Re: [PATCH/RFC] mm: add and use batched version of __tlb_remove_table()
From: Nikita Yushchenko @ 2021-12-18 13:38 UTC (permalink / raw)
To: Sam Ravnborg
Cc: Peter Zijlstra, Catalin Marinas, Dave Hansen, linux-mm,
sparclinux, Will Deacon, linux-arch, linux-s390, Vasily Gorbik,
Aneesh Kumar K.V, x86, Ingo Molnar, Christian Borntraeger,
Arnd Bergmann, Heiko Carstens, Nick Piggin, Borislav Petkov,
Thomas Gleixner, linux-kernel, kernel, Andrew Morton,
linuxppc-dev, David S. Miller
In-Reply-To: <YbzZaFY+ht+bUtcz@ravnborg.org>
17.12.2021 21:39, Sam Ravnborg wrote:
> Hi Nikita,
>
> How about adding the following to tlb.h:
>
> #ifndef __tlb_remove_tables
> static void __tlb_remove_tables(...)
> {
> ....
> }
> #endif
>
> And then the few archs that want to override __tlb_remove_tables
> needs to do a
> #define __tlb_remove_tables __tlb_remove_tables
Hi Sam.
Thanks for you suggestion.
I think that what Peter suggested in the other reply is even better. I will follow that approach.
Nikita
^ permalink raw reply
* Re: [PATCH/RFC] mm: add and use batched version of __tlb_remove_table()
From: Nikita Yushchenko @ 2021-12-18 14:31 UTC (permalink / raw)
To: Dave Hansen, Will Deacon, Aneesh Kumar K.V, Andrew Morton,
Nick Piggin, Peter Zijlstra, Catalin Marinas, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, David S. Miller,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
Arnd Bergmann
Cc: linux-arch, linux-s390, x86, linux-kernel, linux-mm, kernel,
sparclinux, linuxppc-dev
In-Reply-To: <fcbb726d-fe6a-8fe4-20fd-6a10cdef007a@intel.com>
>> This allows archs to optimize it, by
>> freeing multiple tables in a single release_pages() call. This is
>> faster than individual put_page() calls, especially with memcg
>> accounting enabled.
>
> Could we quantify "faster"? There's a non-trivial amount of code being
> added here and it would be nice to back it up with some cold-hard numbers.
I currently don't have numbers for this patch taken alone. This patch originates from work done some
years ago to reduce cost of memory accounting, and x86-only version of this patch was in
virtuozzo/openvz kernel since then. Other patches from that work have been upstreamed, but this one was
missed.
Still it's obvious that release_pages() shall be faster that a loop calling put_page() - isn't that
exactly the reason why release_pages() exists and is different from a loop calling put_page()?
>> static void __tlb_remove_table_free(struct mmu_table_batch *batch)
>> {
>> - int i;
>> -
>> - for (i = 0; i < batch->nr; i++)
>> - __tlb_remove_table(batch->tables[i]);
>> -
>> + __tlb_remove_tables(batch->tables, batch->nr);
>> free_page((unsigned long)batch);
>> }
>
> This leaves a single call-site for __tlb_remove_table():
>
>> static void tlb_remove_table_one(void *table)
>> {
>> tlb_remove_table_sync_one();
>> __tlb_remove_table(table);
>> }
>
> Is that worth it, or could it just be:
>
> __tlb_remove_tables(&table, 1);
I was considering that while preparing the patch, however that resulted into even larger change in
archs, due to removal of non-batched call, and I decided not to follow this way.
And, Peter's suggestion to integrate free_page_and_swap()-based implementation of __tlb_remove_table()
into mm/mmu_gather.c under ifdef, and then do the optimization locally in mm/mmu_gather.c, looks better.
>> +void free_pages_and_swap_cache_nolru(struct page **pages, int nr)
>> +{
>> + __free_pages_and_swap_cache(pages, nr, false);
>> }
>
> This went unmentioned in the changelog. But, it seems like there's a
> specific optimization here. In the exiting code,
> free_pages_and_swap_cache() is wasteful if no page in pages[] is on the
> LRU. It doesn't need the lru_add_drain().
This is a somewhat different topic.
In scope of this patch, the _nolru version was added because there was no lru draining in the looped
call to __tlb_remove_table(). Having it added to the batched version, although won't break things, does
add overhead that was not there before, which is in direct conflict with the original goal.
If the version with draining lru is indeed not needed, it can be cleaned out in scope of a different
patchset.
> if (!do_lru)
> VM_WARN_ON_ONCE_PAGE(PageLRU(pagep[i]),
> pagep[i]);
> free_swap_cache(...);
This looks like a good safety measure, will add it.
> But, even more than that, do all the architectures even need the
> free_swap_cache()?
I was under impression that process page tables are a valid target for swapping out. Although I can be
wrong here.
Nikita
^ permalink raw reply
* Re: [PATCH v1 0/5] Implement livepatch on PPC32
From: Christophe Leroy @ 2021-12-18 16:12 UTC (permalink / raw)
To: Steven Rostedt
Cc: Petr Mladek, Joe Lawrence, linux-s390@vger.kernel.org,
Jiri Kosina, linux-kernel@vger.kernel.org, Ingo Molnar,
Josh Poimboeuf, live-patching@vger.kernel.org, Naveen N . Rao,
Miroslav Benes, linuxppc-dev@lists.ozlabs.org
In-Reply-To: <20211214090148.264f4660@gandalf.local.home>
Le 14/12/2021 à 15:01, Steven Rostedt a écrit :
> On Tue, 14 Dec 2021 08:35:14 +0100
> Christophe Leroy <christophe.leroy@csgroup.eu> wrote:
>
>>> Will continue investigating.
>>>
>>
>> trace_selftest_startup_function_graph() calls register_ftrace_direct()
>> which returns -ENOSUPP because powerpc doesn't select
>> CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS.
>>
>> Should TEST_DIRECT_TRAMP depend on CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS ?
>
> Yes, that should be:
>
> #if defined(CONFIG_DYNAMIC_FTRACE) && \
> defined(CONFIG_HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS)
> #define TEST_DIRECT_TRAMP
> noinline __noclone static void trace_direct_tramp(void) { }
> #endif
>
>
> And make it test it with or without the args.
>
Shouldn't it just be:
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
Because
register_ftrace_direct() depends on that symbol, so if you have
CONFIG_DYNAMIC_FTRACE && CONFIG_HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
but not DYNAMIC_FTRACE_WITH_REGS then
CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS is unset and
register_ftrace_direct() returns -ENOTSUPP
Christophe
^ permalink raw reply
* Re: [patch V3 28/35] PCI/MSI: Simplify pci_irq_get_affinity()
From: Nathan Chancellor @ 2021-12-18 19:04 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Nishanth Menon, Mark Rutland, Stuart Yoder, Will Deacon,
Ashok Raj, Joerg Roedel, Jassi Brar, Sinan Kaya, iommu,
Peter Ujfalusi, Bjorn Helgaas, linux-arm-kernel, Jason Gunthorpe,
linux-pci, xen-devel, Kevin Tian, Arnd Bergmann, Robin Murphy,
Alex Williamson, Cedric Le Goater, Santosh Shilimkar,
Bjorn Helgaas, Megha Dey, Laurentiu Tudor, Juergen Gross,
Tero Kristo, Greg Kroah-Hartman, LKML, Vinod Koul, Marc Zygnier,
dmaengine, linuxppc-dev
In-Reply-To: <87v8zm9pmd.ffs@tglx>
On Sat, Dec 18, 2021 at 11:25:14AM +0100, Thomas Gleixner wrote:
> On Fri, Dec 17 2021 at 15:30, Nathan Chancellor wrote:
> > On Fri, Dec 10, 2021 at 11:19:26PM +0100, Thomas Gleixner wrote:
> > I just bisected a boot failure on my AMD test desktop to this patch as
> > commit f48235900182 ("PCI/MSI: Simplify pci_irq_get_affinity()") in
> > -next. It looks like there is a problem with the NVMe drive after this
> > change according to the logs. Given that the hard drive is not getting
> > mounted for journald to write logs to, I am not really sure how to get
> > them from the machine so I have at least taken a picture of what I see
> > on my screen; open to ideas on that front!
>
> Bah. Fix below.
Tested-by: Nathan Chancellor <nathan@kernel.org>
> Thanks,
>
> tglx
> ---
> diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
> index 71802410e2ab..9b4910befeda 100644
> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c
> @@ -1100,7 +1100,7 @@ EXPORT_SYMBOL(pci_irq_vector);
> */
> const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)
> {
> - int irq = pci_irq_vector(dev, nr);
> + int idx, irq = pci_irq_vector(dev, nr);
> struct msi_desc *desc;
>
> if (WARN_ON_ONCE(irq <= 0))
> @@ -1113,7 +1113,10 @@ const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)
>
> if (WARN_ON_ONCE(!desc->affinity))
> return NULL;
> - return &desc->affinity[nr].mask;
> +
> + /* MSI has a mask array in the descriptor. */
> + idx = dev->msi_enabled ? nr : 0;
> + return &desc->affinity[idx].mask;
> }
> EXPORT_SYMBOL(pci_irq_get_affinity);
>
>
^ permalink raw reply
* Re: [patch V3 28/35] PCI/MSI: Simplify pci_irq_get_affinity()
From: Cédric Le Goater @ 2021-12-18 20:25 UTC (permalink / raw)
To: Thomas Gleixner, Nathan Chancellor
Cc: Nishanth Menon, Mark Rutland, Stuart Yoder, Will Deacon,
Ashok Raj, Marc Zygnier, Joerg Roedel, Jassi Brar, Sinan Kaya,
iommu, Peter Ujfalusi, Bjorn Helgaas, linux-arm-kernel,
Jason Gunthorpe, linux-pci, xen-devel, Kevin Tian, Arnd Bergmann,
Robin Murphy, Alex Williamson, Santosh Shilimkar, Bjorn Helgaas,
Megha Dey, Laurentiu Tudor, Juergen Gross, Tero Kristo,
Greg Kroah-Hartman, LKML, Vinod Koul, dmaengine, linuxppc-dev
In-Reply-To: <87v8zm9pmd.ffs@tglx>
On 12/18/21 11:25, Thomas Gleixner wrote:
> On Fri, Dec 17 2021 at 15:30, Nathan Chancellor wrote:
>> On Fri, Dec 10, 2021 at 11:19:26PM +0100, Thomas Gleixner wrote:
>> I just bisected a boot failure on my AMD test desktop to this patch as
>> commit f48235900182 ("PCI/MSI: Simplify pci_irq_get_affinity()") in
>> -next. It looks like there is a problem with the NVMe drive after this
>> change according to the logs. Given that the hard drive is not getting
>> mounted for journald to write logs to, I am not really sure how to get
>> them from the machine so I have at least taken a picture of what I see
>> on my screen; open to ideas on that front!
>
> Bah. Fix below.
That's a fix for the issue I was seeing on pseries with NVMe.
Tested-by: Cédric Le Goater <clg@kaod.org>
Thanks,
C.
> Thanks,
>
> tglx
> ---
> diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
> index 71802410e2ab..9b4910befeda 100644
> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c
> @@ -1100,7 +1100,7 @@ EXPORT_SYMBOL(pci_irq_vector);
> */
> const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)
> {
> - int irq = pci_irq_vector(dev, nr);
> + int idx, irq = pci_irq_vector(dev, nr);
> struct msi_desc *desc;
>
> if (WARN_ON_ONCE(irq <= 0))
> @@ -1113,7 +1113,10 @@ const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)
>
> if (WARN_ON_ONCE(!desc->affinity))
> return NULL;
> - return &desc->affinity[nr].mask;
> +
> + /* MSI has a mask array in the descriptor. */
> + idx = dev->msi_enabled ? nr : 0;
> + return &desc->affinity[idx].mask;
> }
> EXPORT_SYMBOL(pci_irq_get_affinity);
>
>
^ permalink raw reply
* [PATCH 01/17] all: don't use bitmap_weight() where possible
From: Yury Norov @ 2021-12-18 21:19 UTC (permalink / raw)
To: linux-kernel, Yury Norov, James E.J. Bottomley,
Martin K. Petersen, Michał Mirosław, Paul E. McKenney,
Rafael J. Wysocki, Alexander Shishkin, Alexey Klimov,
Amitkumar Karwar, Andi Kleen, Andrew Lunn, Andrew Morton,
Andy Gross, Andy Lutomirski, Andy Shevchenko, Anup Patel,
Ard Biesheuvel, Arnaldo Carvalho de Melo, Arnd Bergmann,
Borislav Petkov, Catalin Marinas, Christoph Hellwig,
Christoph Lameter, Daniel Vetter, Dave Hansen, David Airlie,
David Laight, Dennis Zhou, Emil Renner Berthing,
Geert Uytterhoeven, Geetha sowjanya, Greg Kroah-Hartman, Guo Ren,
Hans de Goede, Heiko Carstens, Ian Rogers, Ingo Molnar,
Jakub Kicinski, Jason Wessel, Jens Axboe, Jiri Olsa, Joe Perches,
Jonathan Cameron, Juri Lelli, Kees Cook, Krzysztof Kozlowski,
Lee Jones, Marc Zyngier, Marcin Wojtas, Mark Gross, Mark Rutland,
Matti Vaittinen, Mauro Carvalho Chehab, Mel Gorman,
Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Russell King, Saeed Mahameed, Sagi Grimberg,
Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
In-Reply-To: <20211218212014.1315894-1-yury.norov@gmail.com>
Don't call bitmap_weight() if the following code can get by
without it.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/dsa/b53/b53_common.c | 6 +-----
drivers/net/ethernet/broadcom/bcmsysport.c | 6 +-----
drivers/thermal/intel/intel_powerclamp.c | 9 +++------
3 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 3867f3d4545f..9a10d80125d9 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1620,12 +1620,8 @@ static int b53_arl_read(struct b53_device *dev, u64 mac,
return 0;
}
- if (bitmap_weight(free_bins, dev->num_arl_bins) == 0)
- return -ENOSPC;
-
*idx = find_first_bit(free_bins, dev->num_arl_bins);
-
- return -ENOENT;
+ return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT;
}
static int b53_arl_op(struct b53_device *dev, int op, int port,
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 40933bf5a710..241696fdc6c7 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -2177,13 +2177,9 @@ static int bcm_sysport_rule_set(struct bcm_sysport_priv *priv,
if (nfc->fs.ring_cookie != RX_CLS_FLOW_WAKE)
return -EOPNOTSUPP;
- /* All filters are already in use, we cannot match more rules */
- if (bitmap_weight(priv->filters, RXCHK_BRCM_TAG_MAX) ==
- RXCHK_BRCM_TAG_MAX)
- return -ENOSPC;
-
index = find_first_zero_bit(priv->filters, RXCHK_BRCM_TAG_MAX);
if (index >= RXCHK_BRCM_TAG_MAX)
+ /* All filters are already in use, we cannot match more rules */
return -ENOSPC;
/* Location is the classification ID, and index is the position
diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c
index 14256421d98c..c841ab37e7c6 100644
--- a/drivers/thermal/intel/intel_powerclamp.c
+++ b/drivers/thermal/intel/intel_powerclamp.c
@@ -556,12 +556,9 @@ static void end_power_clamp(void)
* stop faster.
*/
clamping = false;
- if (bitmap_weight(cpu_clamping_mask, num_possible_cpus())) {
- for_each_set_bit(i, cpu_clamping_mask, num_possible_cpus()) {
- pr_debug("clamping worker for cpu %d alive, destroy\n",
- i);
- stop_power_clamp_worker(i);
- }
+ for_each_set_bit(i, cpu_clamping_mask, num_possible_cpus()) {
+ pr_debug("clamping worker for cpu %d alive, destroy\n", i);
+ stop_power_clamp_worker(i);
}
}
--
2.30.2
^ permalink raw reply related
* [PATCH v2 00/17] lib/bitmap: optimize bitmap_weight() usage
From: Yury Norov @ 2021-12-18 21:19 UTC (permalink / raw)
To: linux-kernel, Yury Norov, James E.J. Bottomley,
Martin K. Petersen, Michał Mirosław, Paul E. McKenney,
Rafael J. Wysocki, Alexander Shishkin, Alexey Klimov,
Amitkumar Karwar, Andi Kleen, Andrew Lunn, Andrew Morton,
Andy Gross, Andy Lutomirski, Andy Shevchenko, Anup Patel,
Ard Biesheuvel, Arnaldo Carvalho de Melo, Arnd Bergmann,
Borislav Petkov, Catalin Marinas, Christoph Hellwig,
Christoph Lameter, Daniel Vetter, Dave Hansen, David Airlie,
David Laight, Dennis Zhou, Emil Renner Berthing,
Geert Uytterhoeven, Geetha sowjanya, Greg Kroah-Hartman, Guo Ren,
Hans de Goede, Heiko Carstens, Ian Rogers, Ingo Molnar,
Jakub Kicinski, Jason Wessel, Jens Axboe, Jiri Olsa, Joe Perches,
Jonathan Cameron, Juri Lelli, Kees Cook, Krzysztof Kozlowski,
Lee Jones, Marc Zyngier, Marcin Wojtas, Mark Gross, Mark Rutland,
Matti Vaittinen, Mauro Carvalho Chehab, Mel Gorman,
Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Russell King, Saeed Mahameed, Sagi Grimberg,
Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
In many cases people use bitmap_weight()-based functions to compare
the result against a number of expression:
if (cpumask_weight(...) > 1)
do_something();
This may take considerable amount of time on many-cpus machines because
cpumask_weight(...) will traverse every word of underlying cpumask
unconditionally.
We can significantly improve on it for many real cases if stop traversing
the mask as soon as we count cpus to any number greater than 1:
if (cpumask_weight_gt(..., 1))
do_something();
To implement this idea, the series adds bitmap_weight_cmp() function
and bitmap_weight_{eq,gt,ge,lt,le} macros on top of it; corresponding
wrappers in cpumask and nodemask.
There are 3 cpumasks, for which weight is counted frequently: possible,
present and active. They all are read-mostly, and to optimize counting
number of set bits for them, this series adds atomic counters, similarly
to online cpumask.
v1: https://lkml.org/lkml/2021/11/27/339
v2:
- add bitmap_weight_cmp();
- fix bitmap_weight_le semantics and provide full set of {eq,gt,ge,lt,le}
as wrappers around bitmap_weight_cmp();
- don't touch small bitmaps (less than 32 bits) - optimization works
only for large bitmaps;
- move bitmap_weight() == 0 -> bitmap_empty() conversion to a separate
patch, ditto cpumask_weight() and nodes_weight;
- add counters for possible, present and active cpus;
- drop bitmap_empty() where possible;
- various fixes around bit counting that spotted my eyes.
Yury Norov (17):
all: don't use bitmap_weight() where possible
drivers: rename num_*_cpus variables
fix open-coded for_each_set_bit()
all: replace bitmap_weight with bitmap_empty where appropriate
all: replace cpumask_weight with cpumask_empty where appropriate
all: replace nodes_weight with nodes_empty where appropriate
lib/bitmap: add bitmap_weight_{cmp,eq,gt,ge,lt,le} functions
all: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} where
appropriate
lib/cpumask: add cpumask_weight_{eq,gt,ge,lt,le}
lib/nodemask: add nodemask_weight_{eq,gt,ge,lt,le}
lib/nodemask: add num_node_state_eq()
kernel/cpu.c: fix init_cpu_online
kernel/cpu: add num_possible_cpus counter
kernel/cpu: add num_present_cpu counter
kernel/cpu: add num_active_cpu counter
tools/bitmap: sync bitmap_weight
MAINTAINERS: add cpumask and nodemask files to BITMAP_API
MAINTAINERS | 4 +
arch/alpha/kernel/process.c | 2 +-
arch/ia64/kernel/setup.c | 2 +-
arch/ia64/mm/tlb.c | 2 +-
arch/mips/cavium-octeon/octeon-irq.c | 4 +-
arch/mips/kernel/crash.c | 2 +-
arch/nds32/kernel/perf_event_cpu.c | 2 +-
arch/powerpc/kernel/smp.c | 2 +-
arch/powerpc/kernel/watchdog.c | 2 +-
arch/powerpc/xmon/xmon.c | 4 +-
arch/s390/kernel/perf_cpum_cf.c | 2 +-
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 +--
arch/x86/kernel/smpboot.c | 4 +-
arch/x86/kvm/hyperv.c | 8 +-
arch/x86/mm/amdtopology.c | 2 +-
arch/x86/mm/mmio-mod.c | 2 +-
arch/x86/mm/numa_emulation.c | 4 +-
arch/x86/platform/uv/uv_nmi.c | 2 +-
drivers/acpi/numa/srat.c | 2 +-
drivers/cpufreq/qcom-cpufreq-hw.c | 2 +-
drivers/cpufreq/scmi-cpufreq.c | 2 +-
drivers/firmware/psci/psci_checker.c | 2 +-
drivers/gpu/drm/i915/i915_pmu.c | 2 +-
drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c | 2 +-
drivers/hv/channel_mgmt.c | 4 +-
drivers/iio/dummy/iio_simple_dummy_buffer.c | 4 +-
drivers/iio/industrialio-trigger.c | 2 +-
drivers/infiniband/hw/hfi1/affinity.c | 13 +-
drivers/infiniband/hw/qib/qib_file_ops.c | 2 +-
drivers/infiniband/hw/qib/qib_iba7322.c | 2 +-
drivers/irqchip/irq-bcm6345-l1.c | 2 +-
drivers/leds/trigger/ledtrig-cpu.c | 6 +-
drivers/memstick/core/ms_block.c | 4 +-
drivers/net/dsa/b53/b53_common.c | 6 +-
drivers/net/ethernet/broadcom/bcmsysport.c | 6 +-
.../net/ethernet/intel/ice/ice_virtchnl_pf.c | 4 +-
.../net/ethernet/intel/ixgbe/ixgbe_sriov.c | 2 +-
.../marvell/octeontx2/nic/otx2_ethtool.c | 2 +-
.../marvell/octeontx2/nic/otx2_flows.c | 8 +-
.../ethernet/marvell/octeontx2/nic/otx2_pf.c | 2 +-
drivers/net/ethernet/mellanox/mlx4/cmd.c | 33 ++---
drivers/net/ethernet/mellanox/mlx4/eq.c | 4 +-
drivers/net/ethernet/mellanox/mlx4/fw.c | 4 +-
drivers/net/ethernet/mellanox/mlx4/main.c | 2 +-
drivers/net/ethernet/qlogic/qed/qed_rdma.c | 4 +-
drivers/net/ethernet/qlogic/qed/qed_roce.c | 2 +-
drivers/perf/arm-cci.c | 2 +-
drivers/perf/arm_pmu.c | 4 +-
drivers/perf/hisilicon/hisi_uncore_pmu.c | 2 +-
drivers/perf/thunderx2_pmu.c | 4 +-
drivers/perf/xgene_pmu.c | 2 +-
drivers/scsi/lpfc/lpfc_init.c | 2 +-
drivers/scsi/storvsc_drv.c | 6 +-
drivers/soc/fsl/qbman/qman_test_stash.c | 2 +-
drivers/staging/media/tegra-video/vi.c | 2 +-
drivers/thermal/intel/intel_powerclamp.c | 9 +-
include/linux/bitmap.h | 80 +++++++++++
include/linux/cpumask.h | 131 +++++++++++++-----
include/linux/nodemask.h | 40 ++++++
kernel/cpu.c | 54 ++++++++
kernel/irq/affinity.c | 2 +-
kernel/padata.c | 2 +-
kernel/rcu/tree_nocb.h | 4 +-
kernel/rcu/tree_plugin.h | 2 +-
kernel/sched/core.c | 10 +-
kernel/sched/topology.c | 4 +-
kernel/time/clockevents.c | 2 +-
kernel/time/clocksource.c | 2 +-
lib/bitmap.c | 21 +++
mm/mempolicy.c | 2 +-
mm/page_alloc.c | 2 +-
mm/vmstat.c | 4 +-
tools/include/linux/bitmap.h | 44 ++++++
tools/lib/bitmap.c | 20 +++
tools/perf/builtin-c2c.c | 4 +-
tools/perf/util/pmu.c | 2 +-
76 files changed, 480 insertions(+), 183 deletions(-)
--
2.30.2
^ permalink raw reply
* [PATCH 02/17] drivers: rename num_*_cpus variables
From: Yury Norov @ 2021-12-18 21:19 UTC (permalink / raw)
To: linux-kernel, Yury Norov, James E.J. Bottomley,
Martin K. Petersen, Michał Mirosław, Paul E. McKenney,
Rafael J. Wysocki, Alexander Shishkin, Alexey Klimov,
Amitkumar Karwar, Andi Kleen, Andrew Lunn, Andrew Morton,
Andy Gross, Andy Lutomirski, Andy Shevchenko, Anup Patel,
Ard Biesheuvel, Arnaldo Carvalho de Melo, Arnd Bergmann,
Borislav Petkov, Catalin Marinas, Christoph Hellwig,
Christoph Lameter, Daniel Vetter, Dave Hansen, David Airlie,
David Laight, Dennis Zhou, Emil Renner Berthing,
Geert Uytterhoeven, Geetha sowjanya, Greg Kroah-Hartman, Guo Ren,
Hans de Goede, Heiko Carstens, Ian Rogers, Ingo Molnar,
Jakub Kicinski, Jason Wessel, Jens Axboe, Jiri Olsa, Joe Perches,
Jonathan Cameron, Juri Lelli, Kees Cook, Krzysztof Kozlowski,
Lee Jones, Marc Zyngier, Marcin Wojtas, Mark Gross, Mark Rutland,
Matti Vaittinen, Mauro Carvalho Chehab, Mel Gorman,
Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Russell King, Saeed Mahameed, Sagi Grimberg,
Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
In-Reply-To: <20211218212014.1315894-1-yury.norov@gmail.com>
Some drivers declare num_active_cpus and num_present_cpus,
despite that kernel has macros with corresponding names in
linux/cpumask.h, and the drivers include cpumask.h
The following patches switch num_*_cpus() to real functions,
which causes build failures for the drivers.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/leds/trigger/ledtrig-cpu.c | 6 +++---
drivers/scsi/storvsc_drv.c | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/leds/trigger/ledtrig-cpu.c b/drivers/leds/trigger/ledtrig-cpu.c
index 8af4f9bb9cde..767e9749ca41 100644
--- a/drivers/leds/trigger/ledtrig-cpu.c
+++ b/drivers/leds/trigger/ledtrig-cpu.c
@@ -39,7 +39,7 @@ struct led_trigger_cpu {
static DEFINE_PER_CPU(struct led_trigger_cpu, cpu_trig);
static struct led_trigger *trig_cpu_all;
-static atomic_t num_active_cpus = ATOMIC_INIT(0);
+static atomic_t _active_cpus = ATOMIC_INIT(0);
/**
* ledtrig_cpu - emit a CPU event as a trigger
@@ -79,8 +79,8 @@ void ledtrig_cpu(enum cpu_led_event ledevt)
/* Update trigger state */
trig->is_active = is_active;
- atomic_add(is_active ? 1 : -1, &num_active_cpus);
- active_cpus = atomic_read(&num_active_cpus);
+ atomic_add(is_active ? 1 : -1, &_active_cpus);
+ active_cpus = atomic_read(&_active_cpus);
total_cpus = num_present_cpus();
led_trigger_event(trig->_trig,
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 20595c0ba0ae..705dd4ebde98 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1950,7 +1950,7 @@ static int storvsc_probe(struct hv_device *device,
{
int ret;
int num_cpus = num_online_cpus();
- int num_present_cpus = num_present_cpus();
+ int present_cpus = num_present_cpus();
struct Scsi_Host *host;
struct hv_host_device *host_dev;
bool dev_is_ide = ((dev_id->driver_data == IDE_GUID) ? true : false);
@@ -2060,7 +2060,7 @@ static int storvsc_probe(struct hv_device *device,
* Set the number of HW queues we are supporting.
*/
if (!dev_is_ide) {
- if (storvsc_max_hw_queues > num_present_cpus) {
+ if (storvsc_max_hw_queues > present_cpus) {
storvsc_max_hw_queues = 0;
storvsc_log(device, STORVSC_LOGGING_WARN,
"Resetting invalid storvsc_max_hw_queues value to default.\n");
@@ -2068,7 +2068,7 @@ static int storvsc_probe(struct hv_device *device,
if (storvsc_max_hw_queues)
host->nr_hw_queues = storvsc_max_hw_queues;
else
- host->nr_hw_queues = num_present_cpus;
+ host->nr_hw_queues = present_cpus;
}
/*
--
2.30.2
^ permalink raw reply related
* [PATCH 03/17] fix open-coded for_each_set_bit()
From: Yury Norov @ 2021-12-18 21:19 UTC (permalink / raw)
To: linux-kernel, Yury Norov, James E.J. Bottomley,
Martin K. Petersen, Michał Mirosław, Paul E. McKenney,
Rafael J. Wysocki, Alexander Shishkin, Alexey Klimov,
Amitkumar Karwar, Andi Kleen, Andrew Lunn, Andrew Morton,
Andy Gross, Andy Lutomirski, Andy Shevchenko, Anup Patel,
Ard Biesheuvel, Arnaldo Carvalho de Melo, Arnd Bergmann,
Borislav Petkov, Catalin Marinas, Christoph Hellwig,
Christoph Lameter, Daniel Vetter, Dave Hansen, David Airlie,
David Laight, Dennis Zhou, Emil Renner Berthing,
Geert Uytterhoeven, Geetha sowjanya, Greg Kroah-Hartman, Guo Ren,
Hans de Goede, Heiko Carstens, Ian Rogers, Ingo Molnar,
Jakub Kicinski, Jason Wessel, Jens Axboe, Jiri Olsa, Joe Perches,
Jonathan Cameron, Juri Lelli, Kees Cook, Krzysztof Kozlowski,
Lee Jones, Marc Zyngier, Marcin Wojtas, Mark Gross, Mark Rutland,
Matti Vaittinen, Mauro Carvalho Chehab, Mel Gorman,
Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Russell King, Saeed Mahameed, Sagi Grimberg,
Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
In-Reply-To: <20211218212014.1315894-1-yury.norov@gmail.com>
Mellanox driver has an open-coded for_each_set_bit(). Fix it.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
drivers/net/ethernet/mellanox/mlx4/cmd.c | 23 ++++++-----------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index e10b7b04b894..c56d2194cbfc 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -1994,21 +1994,16 @@ static void mlx4_allocate_port_vpps(struct mlx4_dev *dev, int port)
static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int slave)
{
- int port, err;
+ int p, port, err;
struct mlx4_vport_state *vp_admin;
struct mlx4_vport_oper_state *vp_oper;
struct mlx4_slave_state *slave_state =
&priv->mfunc.master.slave_state[slave];
struct mlx4_active_ports actv_ports = mlx4_get_active_ports(
&priv->dev, slave);
- int min_port = find_first_bit(actv_ports.ports,
- priv->dev.caps.num_ports) + 1;
- int max_port = min_port - 1 +
- bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports);
- for (port = min_port; port <= max_port; port++) {
- if (!test_bit(port - 1, actv_ports.ports))
- continue;
+ for_each_set_bit(p, actv_ports.ports, priv->dev.caps.num_ports) {
+ port = p + 1;
priv->mfunc.master.vf_oper[slave].smi_enabled[port] =
priv->mfunc.master.vf_admin[slave].enable_smi[port];
vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port];
@@ -2063,19 +2058,13 @@ static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int slave)
static void mlx4_master_deactivate_admin_state(struct mlx4_priv *priv, int slave)
{
- int port;
+ int p, port;
struct mlx4_vport_oper_state *vp_oper;
struct mlx4_active_ports actv_ports = mlx4_get_active_ports(
&priv->dev, slave);
- int min_port = find_first_bit(actv_ports.ports,
- priv->dev.caps.num_ports) + 1;
- int max_port = min_port - 1 +
- bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports);
-
- for (port = min_port; port <= max_port; port++) {
- if (!test_bit(port - 1, actv_ports.ports))
- continue;
+ for_each_set_bit(p, actv_ports.ports, priv->dev.caps.num_ports) {
+ port = p + 1;
priv->mfunc.master.vf_oper[slave].smi_enabled[port] =
MLX4_VF_SMI_DISABLED;
vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port];
--
2.30.2
^ permalink raw reply related
* [PATCH 04/17] all: replace bitmap_weight with bitmap_empty where appropriate
From: Yury Norov @ 2021-12-18 21:20 UTC (permalink / raw)
To: linux-kernel, Yury Norov, James E.J. Bottomley,
Martin K. Petersen, Michał Mirosław, Paul E. McKenney,
Rafael J. Wysocki, Alexander Shishkin, Alexey Klimov,
Amitkumar Karwar, Andi Kleen, Andrew Lunn, Andrew Morton,
Andy Gross, Andy Lutomirski, Andy Shevchenko, Anup Patel,
Ard Biesheuvel, Arnaldo Carvalho de Melo, Arnd Bergmann,
Borislav Petkov, Catalin Marinas, Christoph Hellwig,
Christoph Lameter, Daniel Vetter, Dave Hansen, David Airlie,
David Laight, Dennis Zhou, Emil Renner Berthing,
Geert Uytterhoeven, Geetha sowjanya, Greg Kroah-Hartman, Guo Ren,
Hans de Goede, Heiko Carstens, Ian Rogers, Ingo Molnar,
Jakub Kicinski, Jason Wessel, Jens Axboe, Jiri Olsa, Joe Perches,
Jonathan Cameron, Juri Lelli, Kees Cook, Krzysztof Kozlowski,
Lee Jones, Marc Zyngier, Marcin Wojtas, Mark Gross, Mark Rutland,
Matti Vaittinen, Mauro Carvalho Chehab, Mel Gorman,
Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Russell King, Saeed Mahameed, Sagi Grimberg,
Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
In-Reply-To: <20211218212014.1315894-1-yury.norov@gmail.com>
In many cases, kernel code calls bitmap_weight() to check if any bit of
a given bitmap is set. It's better to use bitmap_empty() in that case
because bitmap_empty() stops traversing the bitmap as soon as it finds
first set bit, while bitmap_weight() counts all bits unconditionally.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
arch/nds32/kernel/perf_event_cpu.c | 2 +-
arch/x86/kvm/hyperv.c | 8 ++++----
drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c | 2 +-
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 4 ++--
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c | 4 ++--
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 2 +-
drivers/net/ethernet/qlogic/qed/qed_rdma.c | 4 ++--
drivers/net/ethernet/qlogic/qed/qed_roce.c | 2 +-
drivers/perf/arm-cci.c | 2 +-
drivers/perf/arm_pmu.c | 4 ++--
drivers/perf/hisilicon/hisi_uncore_pmu.c | 2 +-
drivers/perf/xgene_pmu.c | 2 +-
tools/perf/builtin-c2c.c | 4 ++--
13 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/arch/nds32/kernel/perf_event_cpu.c b/arch/nds32/kernel/perf_event_cpu.c
index a78a879e7ef1..ea44e9ecb5c7 100644
--- a/arch/nds32/kernel/perf_event_cpu.c
+++ b/arch/nds32/kernel/perf_event_cpu.c
@@ -695,7 +695,7 @@ static void nds32_pmu_enable(struct pmu *pmu)
{
struct nds32_pmu *nds32_pmu = to_nds32_pmu(pmu);
struct pmu_hw_events *hw_events = nds32_pmu->get_hw_events();
- int enabled = bitmap_weight(hw_events->used_mask,
+ bool enabled = !bitmap_empty(hw_events->used_mask,
nds32_pmu->num_events);
if (enabled)
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 6e38a7d22e97..2c3400dea4b3 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -90,7 +90,7 @@ static void synic_update_vector(struct kvm_vcpu_hv_synic *synic,
{
struct kvm_vcpu *vcpu = hv_synic_to_vcpu(synic);
struct kvm_hv *hv = to_kvm_hv(vcpu->kvm);
- int auto_eoi_old, auto_eoi_new;
+ bool auto_eoi_old, auto_eoi_new;
if (vector < HV_SYNIC_FIRST_VALID_VECTOR)
return;
@@ -100,16 +100,16 @@ static void synic_update_vector(struct kvm_vcpu_hv_synic *synic,
else
__clear_bit(vector, synic->vec_bitmap);
- auto_eoi_old = bitmap_weight(synic->auto_eoi_bitmap, 256);
+ auto_eoi_old = bitmap_empty(synic->auto_eoi_bitmap, 256);
if (synic_has_vector_auto_eoi(synic, vector))
__set_bit(vector, synic->auto_eoi_bitmap);
else
__clear_bit(vector, synic->auto_eoi_bitmap);
- auto_eoi_new = bitmap_weight(synic->auto_eoi_bitmap, 256);
+ auto_eoi_new = bitmap_empty(synic->auto_eoi_bitmap, 256);
- if (!!auto_eoi_old == !!auto_eoi_new)
+ if (auto_eoi_old == auto_eoi_new)
return;
down_write(&vcpu->kvm->arch.apicv_update_lock);
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c
index d7fa2c49e741..56a3063545ec 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c
@@ -68,7 +68,7 @@ static int smp_request_block(struct mdp5_smp *smp,
uint8_t reserved;
/* we shouldn't be requesting blocks for an in-use client: */
- WARN_ON(bitmap_weight(cs, cnt) > 0);
+ WARN_ON(!bitmap_empty(cs, cnt));
reserved = smp->reserved[cid];
diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
index 61b2db3342ed..ac0fe04df2e0 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
@@ -267,8 +267,8 @@ ice_set_pfe_link(struct ice_vf *vf, struct virtchnl_pf_event *pfe,
*/
static bool ice_vf_has_no_qs_ena(struct ice_vf *vf)
{
- return (!bitmap_weight(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF) &&
- !bitmap_weight(vf->txq_ena, ICE_MAX_RSS_QS_PER_VF));
+ return (bitmap_empty(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF) &&
+ bitmap_empty(vf->txq_ena, ICE_MAX_RSS_QS_PER_VF));
}
/**
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
index 77a13fb555fb..80b2d64b4136 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
@@ -353,7 +353,7 @@ int otx2_add_macfilter(struct net_device *netdev, const u8 *mac)
{
struct otx2_nic *pf = netdev_priv(netdev);
- if (bitmap_weight(&pf->flow_cfg->dmacflt_bmap,
+ if (!bitmap_empty(&pf->flow_cfg->dmacflt_bmap,
pf->flow_cfg->dmacflt_max_flows))
netdev_warn(netdev,
"Add %pM to CGX/RPM DMAC filters list as well\n",
@@ -436,7 +436,7 @@ int otx2_get_maxflows(struct otx2_flow_config *flow_cfg)
return 0;
if (flow_cfg->nr_flows == flow_cfg->max_flows ||
- bitmap_weight(&flow_cfg->dmacflt_bmap,
+ !bitmap_empty(&flow_cfg->dmacflt_bmap,
flow_cfg->dmacflt_max_flows))
return flow_cfg->max_flows + flow_cfg->dmacflt_max_flows;
else
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
index 6080ebd9bd94..3d369ccc7ab9 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
@@ -1115,7 +1115,7 @@ static int otx2_cgx_config_loopback(struct otx2_nic *pf, bool enable)
struct msg_req *msg;
int err;
- if (enable && bitmap_weight(&pf->flow_cfg->dmacflt_bmap,
+ if (enable && !bitmap_empty(&pf->flow_cfg->dmacflt_bmap,
pf->flow_cfg->dmacflt_max_flows))
netdev_warn(pf->netdev,
"CGX/RPM internal loopback might not work as DMAC filters are active\n");
diff --git a/drivers/net/ethernet/qlogic/qed/qed_rdma.c b/drivers/net/ethernet/qlogic/qed/qed_rdma.c
index 23b668de4640..b6e2e17bac04 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_rdma.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_rdma.c
@@ -336,7 +336,7 @@ void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn,
/* print aligned non-zero lines, if any */
for (item = 0, line = 0; line < last_line; line++, item += 8)
- if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8))
+ if (!bitmap_empty((unsigned long *)&pmap[item], 64 * 8))
DP_NOTICE(p_hwfn,
"line 0x%04x: 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
line,
@@ -350,7 +350,7 @@ void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn,
/* print last unaligned non-zero line, if any */
if ((bmap->max_count % (64 * 8)) &&
- (bitmap_weight((unsigned long *)&pmap[item],
+ (!bitmap_empty((unsigned long *)&pmap[item],
bmap->max_count - item * 64))) {
offset = sprintf(str_last_line, "line 0x%04x: ", line);
for (; item < last_item; item++)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_roce.c b/drivers/net/ethernet/qlogic/qed/qed_roce.c
index 071b4aeaddf2..134ecfca96a3 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_roce.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_roce.c
@@ -76,7 +76,7 @@ void qed_roce_stop(struct qed_hwfn *p_hwfn)
* We delay for a short while if an async destroy QP is still expected.
* Beyond the added delay we clear the bitmap anyway.
*/
- while (bitmap_weight(rcid_map->bitmap, rcid_map->max_count)) {
+ while (!bitmap_empty(rcid_map->bitmap, rcid_map->max_count)) {
/* If the HW device is during recovery, all resources are
* immediately reset without receiving a per-cid indication
* from HW. In this case we don't expect the cid bitmap to be
diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c
index 54aca3a62814..96e09fa40909 100644
--- a/drivers/perf/arm-cci.c
+++ b/drivers/perf/arm-cci.c
@@ -1096,7 +1096,7 @@ static void cci_pmu_enable(struct pmu *pmu)
{
struct cci_pmu *cci_pmu = to_cci_pmu(pmu);
struct cci_pmu_hw_events *hw_events = &cci_pmu->hw_events;
- int enabled = bitmap_weight(hw_events->used_mask, cci_pmu->num_cntrs);
+ bool enabled = !bitmap_empty(hw_events->used_mask, cci_pmu->num_cntrs);
unsigned long flags;
if (!enabled)
diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c
index 295cc7952d0e..a31b302b0ade 100644
--- a/drivers/perf/arm_pmu.c
+++ b/drivers/perf/arm_pmu.c
@@ -524,7 +524,7 @@ static void armpmu_enable(struct pmu *pmu)
{
struct arm_pmu *armpmu = to_arm_pmu(pmu);
struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events);
- int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events);
+ bool enabled = !bitmap_empty(hw_events->used_mask, armpmu->num_events);
/* For task-bound events we may be called on other CPUs */
if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus))
@@ -785,7 +785,7 @@ static int cpu_pm_pmu_notify(struct notifier_block *b, unsigned long cmd,
{
struct arm_pmu *armpmu = container_of(b, struct arm_pmu, cpu_pm_nb);
struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events);
- int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events);
+ bool enabled = !bitmap_empty(hw_events->used_mask, armpmu->num_events);
if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus))
return NOTIFY_DONE;
diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c
index a738aeab5c04..358e4e284a62 100644
--- a/drivers/perf/hisilicon/hisi_uncore_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c
@@ -393,7 +393,7 @@ EXPORT_SYMBOL_GPL(hisi_uncore_pmu_read);
void hisi_uncore_pmu_enable(struct pmu *pmu)
{
struct hisi_pmu *hisi_pmu = to_hisi_pmu(pmu);
- int enabled = bitmap_weight(hisi_pmu->pmu_events.used_mask,
+ bool enabled = !bitmap_empty(hisi_pmu->pmu_events.used_mask,
hisi_pmu->num_counters);
if (!enabled)
diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c
index 2b6d476bd213..88bd100a9633 100644
--- a/drivers/perf/xgene_pmu.c
+++ b/drivers/perf/xgene_pmu.c
@@ -867,7 +867,7 @@ static void xgene_perf_pmu_enable(struct pmu *pmu)
{
struct xgene_pmu_dev *pmu_dev = to_pmu_dev(pmu);
struct xgene_pmu *xgene_pmu = pmu_dev->parent;
- int enabled = bitmap_weight(pmu_dev->cntr_assign_mask,
+ bool enabled = !bitmap_empty(pmu_dev->cntr_assign_mask,
pmu_dev->max_counters);
if (!enabled)
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index b5c67ef73862..51997386fb31 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -1080,7 +1080,7 @@ node_entry(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp *hpp,
bitmap_zero(set, c2c.cpus_cnt);
bitmap_and(set, c2c_he->cpuset, c2c.nodes[node], c2c.cpus_cnt);
- if (!bitmap_weight(set, c2c.cpus_cnt)) {
+ if (bitmap_empty(set, c2c.cpus_cnt)) {
if (c2c.node_info == 1) {
ret = scnprintf(hpp->buf, hpp->size, "%21s", " ");
advance_hpp(hpp, ret);
@@ -1944,7 +1944,7 @@ static int set_nodestr(struct c2c_hist_entry *c2c_he)
if (c2c_he->nodestr)
return 0;
- if (bitmap_weight(c2c_he->nodeset, c2c.nodes_cnt)) {
+ if (!bitmap_empty(c2c_he->nodeset, c2c.nodes_cnt)) {
len = bitmap_scnprintf(c2c_he->nodeset, c2c.nodes_cnt,
buf, sizeof(buf));
} else {
--
2.30.2
^ permalink raw reply related
* [PATCH 05/17] all: replace cpumask_weight with cpumask_empty where appropriate
From: Yury Norov @ 2021-12-18 21:20 UTC (permalink / raw)
To: linux-kernel, Yury Norov, James E.J. Bottomley,
Martin K. Petersen, Michał Mirosław, Paul E. McKenney,
Rafael J. Wysocki, Alexander Shishkin, Alexey Klimov,
Amitkumar Karwar, Andi Kleen, Andrew Lunn, Andrew Morton,
Andy Gross, Andy Lutomirski, Andy Shevchenko, Anup Patel,
Ard Biesheuvel, Arnaldo Carvalho de Melo, Arnd Bergmann,
Borislav Petkov, Catalin Marinas, Christoph Hellwig,
Christoph Lameter, Daniel Vetter, Dave Hansen, David Airlie,
David Laight, Dennis Zhou, Emil Renner Berthing,
Geert Uytterhoeven, Geetha sowjanya, Greg Kroah-Hartman, Guo Ren,
Hans de Goede, Heiko Carstens, Ian Rogers, Ingo Molnar,
Jakub Kicinski, Jason Wessel, Jens Axboe, Jiri Olsa, Joe Perches,
Jonathan Cameron, Juri Lelli, Kees Cook, Krzysztof Kozlowski,
Lee Jones, Marc Zyngier, Marcin Wojtas, Mark Gross, Mark Rutland,
Matti Vaittinen, Mauro Carvalho Chehab, Mel Gorman,
Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Russell King, Saeed Mahameed, Sagi Grimberg,
Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
In-Reply-To: <20211218212014.1315894-1-yury.norov@gmail.com>
In many cases, kernel code calls cpumask_weight() to check if any bit of
a given cpumask is set. We can do it more efficiently with cpumask_empty()
because cpumask_empty() stops traversing the cpumask as soon as it finds
first set bit, while cpumask_weight() counts all bits unconditionally.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
arch/alpha/kernel/process.c | 2 +-
arch/ia64/kernel/setup.c | 2 +-
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 14 +++++++-------
arch/x86/mm/mmio-mod.c | 2 +-
arch/x86/platform/uv/uv_nmi.c | 2 +-
drivers/cpufreq/qcom-cpufreq-hw.c | 2 +-
drivers/cpufreq/scmi-cpufreq.c | 2 +-
drivers/gpu/drm/i915/i915_pmu.c | 2 +-
drivers/infiniband/hw/hfi1/affinity.c | 4 ++--
drivers/irqchip/irq-bcm6345-l1.c | 2 +-
kernel/irq/affinity.c | 2 +-
kernel/padata.c | 2 +-
kernel/rcu/tree_nocb.h | 4 ++--
kernel/rcu/tree_plugin.h | 2 +-
kernel/sched/core.c | 2 +-
kernel/sched/topology.c | 2 +-
kernel/time/clocksource.c | 2 +-
mm/vmstat.c | 4 ++--
18 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index f4759e4ee4a9..a4415ad44982 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -125,7 +125,7 @@ common_shutdown_1(void *generic_ptr)
/* Wait for the secondaries to halt. */
set_cpu_present(boot_cpuid, false);
set_cpu_possible(boot_cpuid, false);
- while (cpumask_weight(cpu_present_mask))
+ while (!cpumask_empty(cpu_present_mask))
barrier();
#endif
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index 5010348fa21b..fd6301eafa9d 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -572,7 +572,7 @@ setup_arch (char **cmdline_p)
#ifdef CONFIG_ACPI_HOTPLUG_CPU
prefill_possible_map();
#endif
- per_cpu_scan_finalize((cpumask_weight(&early_cpu_possible_map) == 0 ?
+ per_cpu_scan_finalize((cpumask_empty(&early_cpu_possible_map) ?
32 : cpumask_weight(&early_cpu_possible_map)),
additional_cpus > 0 ? additional_cpus : 0);
#endif /* CONFIG_ACPI_NUMA */
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index b57b3db9a6a7..e23ff03290b8 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -341,14 +341,14 @@ static int cpus_mon_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
/* Check whether cpus belong to parent ctrl group */
cpumask_andnot(tmpmask, newmask, &prgrp->cpu_mask);
- if (cpumask_weight(tmpmask)) {
+ if (!cpumask_empty(tmpmask)) {
rdt_last_cmd_puts("Can only add CPUs to mongroup that belong to parent\n");
return -EINVAL;
}
/* Check whether cpus are dropped from this group */
cpumask_andnot(tmpmask, &rdtgrp->cpu_mask, newmask);
- if (cpumask_weight(tmpmask)) {
+ if (!cpumask_empty(tmpmask)) {
/* Give any dropped cpus to parent rdtgroup */
cpumask_or(&prgrp->cpu_mask, &prgrp->cpu_mask, tmpmask);
update_closid_rmid(tmpmask, prgrp);
@@ -359,7 +359,7 @@ static int cpus_mon_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
* and update per-cpu rmid
*/
cpumask_andnot(tmpmask, newmask, &rdtgrp->cpu_mask);
- if (cpumask_weight(tmpmask)) {
+ if (!cpumask_empty(tmpmask)) {
head = &prgrp->mon.crdtgrp_list;
list_for_each_entry(crgrp, head, mon.crdtgrp_list) {
if (crgrp == rdtgrp)
@@ -394,7 +394,7 @@ static int cpus_ctrl_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
/* Check whether cpus are dropped from this group */
cpumask_andnot(tmpmask, &rdtgrp->cpu_mask, newmask);
- if (cpumask_weight(tmpmask)) {
+ if (!cpumask_empty(tmpmask)) {
/* Can't drop from default group */
if (rdtgrp == &rdtgroup_default) {
rdt_last_cmd_puts("Can't drop CPUs from default group\n");
@@ -413,12 +413,12 @@ static int cpus_ctrl_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
* and update per-cpu closid/rmid.
*/
cpumask_andnot(tmpmask, newmask, &rdtgrp->cpu_mask);
- if (cpumask_weight(tmpmask)) {
+ if (!cpumask_empty(tmpmask)) {
list_for_each_entry(r, &rdt_all_groups, rdtgroup_list) {
if (r == rdtgrp)
continue;
cpumask_and(tmpmask1, &r->cpu_mask, tmpmask);
- if (cpumask_weight(tmpmask1))
+ if (!cpumask_empty(tmpmask1))
cpumask_rdtgrp_clear(r, tmpmask1);
}
update_closid_rmid(tmpmask, rdtgrp);
@@ -488,7 +488,7 @@ static ssize_t rdtgroup_cpus_write(struct kernfs_open_file *of,
/* check that user didn't specify any offline cpus */
cpumask_andnot(tmpmask, newmask, cpu_online_mask);
- if (cpumask_weight(tmpmask)) {
+ if (!cpumask_empty(tmpmask)) {
ret = -EINVAL;
rdt_last_cmd_puts("Can only assign online CPUs\n");
goto unlock;
diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
index 933a2ebad471..c3317f0650d8 100644
--- a/arch/x86/mm/mmio-mod.c
+++ b/arch/x86/mm/mmio-mod.c
@@ -400,7 +400,7 @@ static void leave_uniprocessor(void)
int cpu;
int err;
- if (!cpumask_available(downed_cpus) || cpumask_weight(downed_cpus) == 0)
+ if (!cpumask_available(downed_cpus) || cpumask_empty(downed_cpus))
return;
pr_notice("Re-enabling CPUs...\n");
for_each_cpu(cpu, downed_cpus) {
diff --git a/arch/x86/platform/uv/uv_nmi.c b/arch/x86/platform/uv/uv_nmi.c
index 1e9ff28bc2e0..ea277fc08357 100644
--- a/arch/x86/platform/uv/uv_nmi.c
+++ b/arch/x86/platform/uv/uv_nmi.c
@@ -985,7 +985,7 @@ static int uv_handle_nmi(unsigned int reason, struct pt_regs *regs)
/* Clear global flags */
if (master) {
- if (cpumask_weight(uv_nmi_cpu_mask))
+ if (!cpumask_empty(uv_nmi_cpu_mask))
uv_nmi_cleanup_mask();
atomic_set(&uv_nmi_cpus_in_nmi, -1);
atomic_set(&uv_nmi_cpu, -1);
diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
index 05f3d7876e44..95a0c57ab5bb 100644
--- a/drivers/cpufreq/qcom-cpufreq-hw.c
+++ b/drivers/cpufreq/qcom-cpufreq-hw.c
@@ -482,7 +482,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
}
qcom_get_related_cpus(index, policy->cpus);
- if (!cpumask_weight(policy->cpus)) {
+ if (cpumask_empty(policy->cpus)) {
dev_err(dev, "Domain-%d failed to get related CPUs\n", index);
ret = -ENOENT;
goto error;
diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index 1e0cd4d165f0..919fa6e3f462 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -154,7 +154,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
* table and opp-shared.
*/
ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, priv->opp_shared_cpus);
- if (ret || !cpumask_weight(priv->opp_shared_cpus)) {
+ if (ret || cpumask_empty(priv->opp_shared_cpus)) {
/*
* Either opp-table is not set or no opp-shared was found.
* Use the CPU mask from SCMI to designate CPUs sharing an OPP
diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
index 0b488d49694c..962e8d6bf6ea 100644
--- a/drivers/gpu/drm/i915/i915_pmu.c
+++ b/drivers/gpu/drm/i915/i915_pmu.c
@@ -1048,7 +1048,7 @@ static int i915_pmu_cpu_online(unsigned int cpu, struct hlist_node *node)
GEM_BUG_ON(!pmu->base.event_init);
/* Select the first online CPU as a designated reader. */
- if (!cpumask_weight(&i915_pmu_cpumask))
+ if (cpumask_empty(&i915_pmu_cpumask))
cpumask_set_cpu(cpu, &i915_pmu_cpumask);
return 0;
diff --git a/drivers/infiniband/hw/hfi1/affinity.c b/drivers/infiniband/hw/hfi1/affinity.c
index 98c813ba4304..38eee675369a 100644
--- a/drivers/infiniband/hw/hfi1/affinity.c
+++ b/drivers/infiniband/hw/hfi1/affinity.c
@@ -667,7 +667,7 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd)
* engines, use the same CPU cores as general/control
* context.
*/
- if (cpumask_weight(&entry->def_intr.mask) == 0)
+ if (cpumask_empty(&entry->def_intr.mask))
cpumask_copy(&entry->def_intr.mask,
&entry->general_intr_mask);
}
@@ -687,7 +687,7 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd)
* vectors, use the same CPU core as the general/control
* context.
*/
- if (cpumask_weight(&entry->comp_vect_mask) == 0)
+ if (cpumask_empty(&entry->comp_vect_mask))
cpumask_copy(&entry->comp_vect_mask,
&entry->general_intr_mask);
}
diff --git a/drivers/irqchip/irq-bcm6345-l1.c b/drivers/irqchip/irq-bcm6345-l1.c
index fd079215c17f..142a7431745f 100644
--- a/drivers/irqchip/irq-bcm6345-l1.c
+++ b/drivers/irqchip/irq-bcm6345-l1.c
@@ -315,7 +315,7 @@ static int __init bcm6345_l1_of_init(struct device_node *dn,
cpumask_set_cpu(idx, &intc->cpumask);
}
- if (!cpumask_weight(&intc->cpumask)) {
+ if (cpumask_empty(&intc->cpumask)) {
ret = -ENODEV;
goto out_free;
}
diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c
index f7ff8919dc9b..18740faf0eb1 100644
--- a/kernel/irq/affinity.c
+++ b/kernel/irq/affinity.c
@@ -258,7 +258,7 @@ static int __irq_build_affinity_masks(unsigned int startvec,
nodemask_t nodemsk = NODE_MASK_NONE;
struct node_vectors *node_vectors;
- if (!cpumask_weight(cpu_mask))
+ if (cpumask_empty(cpu_mask))
return 0;
nodes = get_nodes_in_cpumask(node_to_cpumask, cpu_mask, &nodemsk);
diff --git a/kernel/padata.c b/kernel/padata.c
index 18d3a5c699d8..e5819bb8bd1d 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -181,7 +181,7 @@ int padata_do_parallel(struct padata_shell *ps,
goto out;
if (!cpumask_test_cpu(*cb_cpu, pd->cpumask.cbcpu)) {
- if (!cpumask_weight(pd->cpumask.cbcpu))
+ if (cpumask_empty(pd->cpumask.cbcpu))
goto out;
/* Select an alternate fallback CPU and notify the caller. */
diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
index 1e40519d1a05..bc038a451768 100644
--- a/kernel/rcu/tree_nocb.h
+++ b/kernel/rcu/tree_nocb.h
@@ -1169,7 +1169,7 @@ void __init rcu_init_nohz(void)
struct rcu_data *rdp;
#if defined(CONFIG_NO_HZ_FULL)
- if (tick_nohz_full_running && cpumask_weight(tick_nohz_full_mask))
+ if (tick_nohz_full_running && !cpumask_empty(tick_nohz_full_mask))
need_rcu_nocb_mask = true;
#endif /* #if defined(CONFIG_NO_HZ_FULL) */
@@ -1353,7 +1353,7 @@ static void __init rcu_organize_nocb_kthreads(void)
*/
void rcu_bind_current_to_nocb(void)
{
- if (cpumask_available(rcu_nocb_mask) && cpumask_weight(rcu_nocb_mask))
+ if (cpumask_available(rcu_nocb_mask) && !cpumask_empty(rcu_nocb_mask))
WARN_ON(sched_setaffinity(current->pid, rcu_nocb_mask));
}
EXPORT_SYMBOL_GPL(rcu_bind_current_to_nocb);
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 54ef0e8c8742..3857ff6cb6f7 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -1216,7 +1216,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
cpu != outgoingcpu)
cpumask_set_cpu(cpu, cm);
cpumask_and(cm, cm, housekeeping_cpumask(HK_FLAG_RCU));
- if (cpumask_weight(cm) == 0)
+ if (cpumask_empty(cm))
cpumask_copy(cm, housekeeping_cpumask(HK_FLAG_RCU));
set_cpus_allowed_ptr(t, cm);
mutex_unlock(&rnp->boost_kthread_mutex);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 83872f95a1ea..9b3ec14227e1 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8715,7 +8715,7 @@ int cpuset_cpumask_can_shrink(const struct cpumask *cur,
{
int ret = 1;
- if (!cpumask_weight(cur))
+ if (cpumask_empty(cur))
return ret;
ret = dl_cpuset_cpumask_can_shrink(cur, trial);
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index d201a7052a29..8478e2a8cd65 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -74,7 +74,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
break;
}
- if (!cpumask_weight(sched_group_span(group))) {
+ if (cpumask_empty(sched_group_span(group))) {
printk(KERN_CONT "\n");
printk(KERN_ERR "ERROR: empty group\n");
break;
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 95d7ca35bdf2..cee5da1e54c4 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -343,7 +343,7 @@ void clocksource_verify_percpu(struct clocksource *cs)
cpus_read_lock();
preempt_disable();
clocksource_verify_choose_cpus();
- if (cpumask_weight(&cpus_chosen) == 0) {
+ if (cpumask_empty(&cpus_chosen)) {
preempt_enable();
cpus_read_unlock();
pr_warn("Not enough CPUs to check clocksource '%s'.\n", cs->name);
diff --git a/mm/vmstat.c b/mm/vmstat.c
index d701c335628c..295642e2c24c 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -2032,7 +2032,7 @@ static void __init init_cpu_node_state(void)
int node;
for_each_online_node(node) {
- if (cpumask_weight(cpumask_of_node(node)) > 0)
+ if (!cpumask_empty(cpumask_of_node(node)))
node_set_state(node, N_CPU);
}
}
@@ -2059,7 +2059,7 @@ static int vmstat_cpu_dead(unsigned int cpu)
refresh_zone_stat_thresholds();
node_cpus = cpumask_of_node(node);
- if (cpumask_weight(node_cpus) > 0)
+ if (!cpumask_empty(node_cpus))
return 0;
node_clear_state(node, N_CPU);
--
2.30.2
^ permalink raw reply related
* [PATCH 06/17] all: replace nodes_weight with nodes_empty where appropriate
From: Yury Norov @ 2021-12-18 21:20 UTC (permalink / raw)
To: linux-kernel, Yury Norov, James E.J. Bottomley,
Martin K. Petersen, Michał Mirosław, Paul E. McKenney,
Rafael J. Wysocki, Alexander Shishkin, Alexey Klimov,
Amitkumar Karwar, Andi Kleen, Andrew Lunn, Andrew Morton,
Andy Gross, Andy Lutomirski, Andy Shevchenko, Anup Patel,
Ard Biesheuvel, Arnaldo Carvalho de Melo, Arnd Bergmann,
Borislav Petkov, Catalin Marinas, Christoph Hellwig,
Christoph Lameter, Daniel Vetter, Dave Hansen, David Airlie,
David Laight, Dennis Zhou, Emil Renner Berthing,
Geert Uytterhoeven, Geetha sowjanya, Greg Kroah-Hartman, Guo Ren,
Hans de Goede, Heiko Carstens, Ian Rogers, Ingo Molnar,
Jakub Kicinski, Jason Wessel, Jens Axboe, Jiri Olsa, Joe Perches,
Jonathan Cameron, Juri Lelli, Kees Cook, Krzysztof Kozlowski,
Lee Jones, Marc Zyngier, Marcin Wojtas, Mark Gross, Mark Rutland,
Matti Vaittinen, Mauro Carvalho Chehab, Mel Gorman,
Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Russell King, Saeed Mahameed, Sagi Grimberg,
Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
In-Reply-To: <20211218212014.1315894-1-yury.norov@gmail.com>
Kernel code calls nodes_weight() to check if any bit of a given nodemask is
set. We can do it more efficiently with nodes_empty() because nodes_empty()
stops traversing the nodemask as soon as it finds first set bit, while
nodes_weight() counts all bits unconditionally.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
arch/x86/mm/amdtopology.c | 2 +-
arch/x86/mm/numa_emulation.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/mm/amdtopology.c b/arch/x86/mm/amdtopology.c
index 058b2f36b3a6..b3ca7d23e4b0 100644
--- a/arch/x86/mm/amdtopology.c
+++ b/arch/x86/mm/amdtopology.c
@@ -154,7 +154,7 @@ int __init amd_numa_init(void)
node_set(nodeid, numa_nodes_parsed);
}
- if (!nodes_weight(numa_nodes_parsed))
+ if (nodes_empty(numa_nodes_parsed))
return -ENOENT;
/*
diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c
index 1a02b791d273..9a9305367fdd 100644
--- a/arch/x86/mm/numa_emulation.c
+++ b/arch/x86/mm/numa_emulation.c
@@ -123,7 +123,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei,
* Continue to fill physical nodes with fake nodes until there is no
* memory left on any of them.
*/
- while (nodes_weight(physnode_mask)) {
+ while (!nodes_empty(physnode_mask)) {
for_each_node_mask(i, physnode_mask) {
u64 dma32_end = PFN_PHYS(MAX_DMA32_PFN);
u64 start, limit, end;
@@ -270,7 +270,7 @@ static int __init split_nodes_size_interleave_uniform(struct numa_meminfo *ei,
* Fill physical nodes with fake nodes of size until there is no memory
* left on any of them.
*/
- while (nodes_weight(physnode_mask)) {
+ while (!nodes_empty(physnode_mask)) {
for_each_node_mask(i, physnode_mask) {
u64 dma32_end = PFN_PHYS(MAX_DMA32_PFN);
u64 start, limit, end;
--
2.30.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox