public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yury Norov <yury.norov@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	"Md. Haris Iqbal" <haris.iqbal@ionos.com>,
	Akinobu Mita <akinobu.mita@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Borislav Petkov <bp@alien8.de>,
	Chaitanya Kulkarni <kch@nvidia.com>,
	Christian Brauner <brauner@kernel.org>,
	Damien Le Moal <damien.lemoal@opensource.wdc.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	David Disseldorp <ddiss@suse.de>,
	Edward Cree <ecree.xilinx@gmail.com>,
	Eric Dumazet <edumazet@google.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Gregory Greenman <gregory.greenman@intel.com>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Hans de Goede <hdegoede@redhat.com>,
	Hugh Dickins <hughd@google.com>, Ingo Molnar <mingo@redhat.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Jaroslav Kysela <perex@perex.cz>, Jason Gunthorpe <jgg@ziepe.ca>,
	Jens Axboe <axboe@kernel.dk>, Jiri Pirko <jiri@resnulli.us>,
	Jiri Slaby <jirislaby@kernel.org>, Kalle Valo <kvalo@kernel.org>,
	Karsten Graul <kgraul@linux.ibm.com>,
	Karsten Keil <isdn@linux-pingi.de>,
	Kees Cook <keescook@chromium.org>,
	Leon Romanovsky <leon@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Martin Habets <habetsm.xilinx@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Michal Simek <monstr@monstr.eu>,
	Nicholas Piggin <npiggin@gmail.com>,
	Oliver Neukum <oneukum@suse.com>, Paolo Abeni <pabeni@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ping-Ke Shih <pkshih@realtek.com>, Rich Felker <dalias@libc.org>,
	Rob Herring <robh@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Sean Christopherson <seanjc@google.com>,
	Shuai Xue <xueshuai@linux.alibaba.com>,
	Stanislaw Gruszka <stf_xl@wp.pl>,
	Steven Rostedt <rostedt@goodmis.org>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Valentin Schneider <vschneid@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wenjia Zhang <wenjia@linux.ibm.com>,
	Will Deacon <will@kernel.org>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	GR-QLogic-Storage-Upstream@marvell.com,
	alsa-devel@alsa-project.org, ath10k@lists.infradead.org,
	dmaengine@vger.kernel.org, iommu@lists.linux.dev,
	kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org, linux-block@vger.kernel.org,
	linux-bluetooth@vger.kernel.org, linux-hyperv@vger.kernel.org,
	linux-m68k@lists.linux-m68k.org, linux-media@vger.kernel.org,
	linux-mips@vger.kernel.org, linux-net-drivers@amd.com,
	linux-pci@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org,
	linux-serial@vger.kernel.org, linux-sh@vger.kernel.org,
	linux-sound@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-wireless@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	mpi3mr-linuxdrv.pdl@broadcom.com, netdev@vger.kernel.org,
	sparclinux@vger.kernel.org, x86@kernel.org,
	Alexey Klimov <alexey.klimov@linaro.org>,
	Bart Van Assche <bvanassche@acm.org>, Jan Kara <jack@suse.cz>,
	Matthew Wilcox <willy@infradead.org>,
	Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Sergey Shtylyov <s.shtylyov@omp.ru>
Subject: Re: [PATCH v4 00/40] lib/find: add atomic find_bit() primitives
Date: Thu, 20 Jun 2024 13:20:20 -0700	[thread overview]
Message-ID: <ZnSPBFW5wL0D0b86@yury-ThinkPad> (raw)
In-Reply-To: <CAHk-=wjv-DkukaKb7f04WezyPjRERp=xfxv34j5fA8cDQ_JudA@mail.gmail.com>

On Thu, Jun 20, 2024 at 12:26:18PM -0700, Linus Torvalds wrote:
> On Thu, 20 Jun 2024 at 11:32, Yury Norov <yury.norov@gmail.com> wrote:
> >
> > Is that in master already? I didn't get any email, and I can't find
> > anything related in the master branch.
> 
> It's 5d272dd1b343 ("cpumask: limit FORCE_NR_CPUS to just the UP case").

FORCE_NR_CPUS helped to generate a better code for me back then. I'll
check again against the current kernel.

The 5d272dd1b343 is wrong. Limiting FORCE_NR_CPUS to UP case makes no
sense because in UP case nr_cpu_ids is already a compile-time macro:

#if (NR_CPUS == 1) || defined(CONFIG_FORCE_NR_CPUS)
#define nr_cpu_ids ((unsigned int)NR_CPUS)
#else
extern unsigned int nr_cpu_ids;
#endif

I use FORCE_NR_CPUS for my Rpi. (used, until I burnt it)

> > > New rule: before you send some optimization, you need to have NUMBERS.
> >
> > I tried to underline that it's not a performance optimization at my
> > best.
> 
> If it's not about performance, then it damn well shouldn't be 90%
> inline functions in a header file.
> 
> If it's a helper function, it needs to be a real function elsewhere. Not this:
> 
>  include/linux/find_atomic.h                  | 324 +++++++++++++++++++
> 
> because either performance really matters, in which case you need to
> show profiles, or performance doesn't matter, in which case it damn
> well shouldn't have special cases for small bitsets that double the
> size of the code.

This small_const_nbits() thing is a compile-time optimization for a
single-word bitmap with a compile-time length.

If the bitmap is longer, or nbits is not known at compile time, the
inline part goes away entirely at compile time.

In the other case, outline part goes away. So those converting from
find_bit() + test_and_set_bit() will see no new outline function
calls.

This inline + outline implementation is traditional for bitmaps, and
for some people it's important. For example, Sean Christopherson
explicitly asked to add a notice that converting to the new API will
still generate inline code. See patch #13.

  reply	other threads:[~2024-06-20 20:20 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-20 17:56 [PATCH v4 00/40] lib/find: add atomic find_bit() primitives Yury Norov
2024-06-20 17:56 ` [PATCH v4 01/40] " Yury Norov
2024-06-20 17:56 ` [PATCH v4 02/40] lib/find: add test for atomic find_bit() ops Yury Norov
2024-06-20 17:56 ` [PATCH v4 03/40] lib/sbitmap; optimize __sbitmap_get_word() by using find_and_set_bit() Yury Norov
2024-06-20 17:56 ` [PATCH v4 04/40] watch_queue: optimize post_one_notification() by using find_and_clear_bit() Yury Norov
2024-06-20 17:56 ` [PATCH v4 05/40] sched: add cpumask_find_and_set() and use it in __mm_cid_get() Yury Norov
2024-06-20 17:56 ` [PATCH v4 06/40] mips: sgi-ip30: optimize heart_alloc_int() by using find_and_set_bit() Yury Norov
2024-06-20 17:56 ` [PATCH v4 07/40] sparc: optimize alloc_msi() " Yury Norov
2024-06-20 17:56 ` [PATCH v4 08/40] perf/arm: use atomic find_bit() API Yury Norov
2024-06-20 17:56 ` [PATCH v4 09/40] drivers/perf: optimize ali_drw_get_counter_idx() by using find_and_set_bit() Yury Norov
2024-06-20 17:56 ` [PATCH v4 10/40] dmaengine: idxd: optimize perfmon_assign_event() Yury Norov
2024-06-20 17:56 ` [PATCH v4 11/40] ath10k: optimize ath10k_snoc_napi_poll() Yury Norov
2024-06-20 17:56 ` [PATCH v4 12/40] wifi: rtw88: optimize the driver by using atomic iterator Yury Norov
2024-06-20 17:56 ` [PATCH v4 13/40] KVM: x86: hyper-v: optimize and cleanup kvm_hv_process_stimers() Yury Norov
2024-06-20 17:56 ` [PATCH v4 14/40] PCI: hv: Optimize hv_get_dom_num() by using find_and_set_bit() Yury Norov
2024-06-20 17:56 ` [PATCH v4 15/40] scsi: core: optimize scsi_evt_emit() by using an atomic iterator Yury Norov
2024-06-20 17:56 ` [PATCH v4 16/40] scsi: mpi3mr: optimize the driver by using find_and_set_bit() Yury Norov
2024-06-20 17:56 ` [PATCH v4 17/40] scsi: qedi: optimize qedi_get_task_idx() " Yury Norov
2024-06-20 17:56 ` [PATCH v4 18/40] powerpc: optimize arch code by using atomic find_bit() API Yury Norov
2024-06-20 17:56 ` [PATCH v4 19/40] iommu: optimize subsystem " Yury Norov
2024-06-25 12:16   ` Joerg Roedel
2024-06-20 17:56 ` [PATCH v4 20/40] media: radio-shark: optimize the driver " Yury Norov
2024-06-20 17:56 ` [PATCH v4 21/40] sfc: " Yury Norov
2024-06-20 17:56 ` [PATCH v4 22/40] tty: nozomi: optimize interrupt_handler() Yury Norov
2024-06-20 17:56 ` [PATCH v4 23/40] usb: cdc-acm: optimize acm_softint() Yury Norov
2024-06-27 14:03   ` Greg Kroah-Hartman
2024-06-20 17:56 ` [PATCH v4 24/40] RDMA/rtrs: optimize __rtrs_get_permit() by using find_and_set_bit_lock() Yury Norov
2024-06-27 12:59   ` Jinpu Wang
2024-06-20 17:56 ` [PATCH v4 25/40] mISDN: optimize get_free_devid() Yury Norov
2024-06-20 17:56 ` [PATCH v4 26/40] media: em28xx: cx231xx: optimize drivers by using find_and_set_bit() Yury Norov
2024-06-20 17:56 ` [PATCH v4 27/40] ethernet: rocker: optimize ofdpa_port_internal_vlan_id_get() Yury Norov
2024-06-20 17:56 ` [PATCH v4 28/40] bluetooth: optimize cmtp_alloc_block_id() Yury Norov
2024-06-20 17:56 ` [PATCH v4 29/40] net: smc: optimize smc_wr_tx_get_free_slot_index() Yury Norov
2024-06-20 17:56 ` [PATCH v4 30/40] ALSA: use atomic find_bit() functions where applicable Yury Norov
2024-06-20 17:56 ` [PATCH v4 31/40] m68k: optimize get_mmu_context() Yury Norov
2024-06-20 17:56 ` [PATCH v4 32/40] microblaze: " Yury Norov
2024-06-20 17:56 ` [PATCH v4 33/40] sh: mach-x3proto: optimize ilsel_enable() Yury Norov
2024-06-21  8:48   ` John Paul Adrian Glaubitz
2024-06-21 14:30     ` Yury Norov
2024-06-20 17:56 ` [PATCH v4 34/40] MIPS: sgi-ip27: optimize alloc_level() Yury Norov
2024-06-20 17:56 ` [PATCH v4 35/40] uprobes: optimize xol_take_insn_slot() Yury Norov
2024-06-20 17:56 ` [PATCH v4 36/40] scsi: sr: drop locking around SR index bitmap Yury Norov
2024-06-20 17:57 ` [PATCH v4 37/40] KVM: PPC: Book3s HV: drop locking around kvmppc_uvmem_bitmap Yury Norov
2024-06-20 17:57 ` [PATCH v4 38/40] wifi: mac80211: drop locking around ntp_fltr_bmap Yury Norov
2024-06-20 17:57 ` [PATCH v4 39/40] mailbox: bcm-flexrm: simplify locking scheme Yury Norov
2024-06-20 17:57 ` [PATCH v4 40/40] powerpc/xive: drop locking around IRQ map Yury Norov
2024-06-20 18:00 ` [PATCH v4 00/40] lib/find: add atomic find_bit() primitives Linus Torvalds
2024-06-20 18:32   ` Yury Norov
2024-06-20 19:26     ` Linus Torvalds
2024-06-20 20:20       ` Yury Norov [this message]
2024-06-20 20:32         ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZnSPBFW5wL0D0b86@yury-ThinkPad \
    --to=yury.norov@gmail.com \
    --cc=GR-QLogic-Storage-Upstream@marvell.com \
    --cc=akinobu.mita@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexey.klimov@linaro.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=andersson@kernel.org \
    --cc=ath10k@lists.infradead.org \
    --cc=axboe@kernel.dk \
    --cc=bp@alien8.de \
    --cc=brauner@kernel.org \
    --cc=bvanassche@acm.org \
    --cc=dalias@libc.org \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=ddiss@suse.de \
    --cc=dmaengine@vger.kernel.org \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@google.com \
    --cc=fenghua.yu@intel.com \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=gregory.greenman@intel.com \
    --cc=habetsm.xilinx@gmail.com \
    --cc=haris.iqbal@ionos.com \
    --cc=hdegoede@redhat.com \
    --cc=hpa@zytor.com \
    --cc=hughd@google.com \
    --cc=hverkuil@xs4all.nl \
    --cc=iommu@lists.linux.dev \
    --cc=isdn@linux-pingi.de \
    --cc=jack@suse.cz \
    --cc=jejb@linux.ibm.com \
    --cc=jgg@ziepe.ca \
    --cc=jiri@resnulli.us \
    --cc=jirislaby@kernel.org \
    --cc=kch@nvidia.com \
    --cc=keescook@chromium.org \
    --cc=kgraul@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kys@microsoft.com \
    --cc=leon@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-net-drivers@amd.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mark.rutland@arm.com \
    --cc=mchehab@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mirsad.todorovac@alu.unizg.hr \
    --cc=monstr@monstr.eu \
    --cc=mpe@ellerman.id.au \
    --cc=mpi3mr-linuxdrv.pdl@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=npiggin@gmail.com \
    --cc=oneukum@suse.com \
    --cc=pabeni@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=perex@perex.cz \
    --cc=peterz@infradead.org \
    --cc=pkshih@realtek.com \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=rostedt@goodmis.org \
    --cc=s.shtylyov@omp.ru \
    --cc=seanjc@google.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=stf_xl@wp.pl \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=vkuznets@redhat.com \
    --cc=vschneid@redhat.com \
    --cc=wenjia@linux.ibm.com \
    --cc=will@kernel.org \
    --cc=willy@infradead.org \
    --cc=x86@kernel.org \
    --cc=xueshuai@linux.alibaba.com \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox