From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 295AE1B9AAF for ; Thu, 20 Jun 2024 20:20:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718914825; cv=none; b=GPEiuPiLYxEqO9IReYyEczJGeZHl6zkxmzRCfmmsRVZ5KCjf8GD6SuhmzeutOvsMvFI8aNwbugF9MhQhdiEfZ+ODGKX41T3xDf+NFEnZc5gVXP+P6nIDiFVFw7w3iFu11ozMbC3QziHIVUHbtQnQ6StoWm4Yzy9z1m4UlGNyJiQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718914825; c=relaxed/simple; bh=rBq7IdJM+K+0+xUcWM1SpeYU9dZrL3Z/PWGHq/TQFvc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HSRzNSHPPr+ZTvjq4aWqdUVgLUScG0IwfpJKRivATIxsGMj4uK1IDmVCev0eXxYZ0ns7qM2FIMY2M0e3DLfhsXDX0kITql5YCRMzYvUgIx5VBZbEO4aqNKpH7r+Bc4mQSwCTgNV2Stidwn9HgyLQ6ZVBWeRhnRcr583kDDH+q7g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OuOGTX7y; arc=none smtp.client-ip=209.85.215.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OuOGTX7y" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-6c4926bf9bbso918259a12.2 for ; Thu, 20 Jun 2024 13:20:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718914823; x=1719519623; darn=lists.linux-m68k.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=xyF3zFimLRvnxw2fNLWvvt4TaZ4/tRThw/CSNxiuI4k=; b=OuOGTX7yDQm2xzyVKCEeAFFAmczBKmHE7HL5VWoGbKRpONnr1iKez62Z8hREP2Loki 2Lhgva9Q2PlHXTl2YVEVHQn6D0DbRz4sMNlV6iI/1WuRNCmX+ri75UcJOHI1eOrGpNZf rnYUULHgHpeFuX4NNUc2iyG0KjghQORI+OrsacQILvBg533sduPWwkvHFLRDbb2HJRGi Ukjjt/hYJuE0KEDXZgS/sFmE1v7BDDJEVcUpxFwmi0Ly9CDeNXuyVuAgf+wa1pohrUfk lZKdM96BcqzvJ6pr5+ql86o0oMxBgY2Yi1eJ2G2mSvXxu38co3uxO/dBxmifE9OXegdo Ed6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718914823; x=1719519623; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xyF3zFimLRvnxw2fNLWvvt4TaZ4/tRThw/CSNxiuI4k=; b=QcX8o27G325uArRqO2O3NVBnaMdO2iJuPSj1BtjXGjztRcFasdzW44aohPiwlJH9fD lzjbCy2vdE4nsQRbL6xJ5nC+IgAX5Fg16Ub1b9qIAGg5WpBRSboiRVd/aaDohvRWK5Vr VWLy1yNuIHwn1mAhhHS2esCVROoCDdh9ljEjn5y9FGQFgbytW7RGTC67MvMS/ftf83Gd ErkGPwZw8UDdCZFX0FVdMcz1HSroDY4mR4EHlBpDNfpTml+RkOjbieyPCxRC1/sa9uhM U7BTq20OT9+AL2T+jPSDq6hMnct7C4G/7t3tzQZYLH/9zSVpiww7MW5pDXlq3DTcqlzO cdVw== X-Forwarded-Encrypted: i=1; AJvYcCWI46ETum3sC/YMNH5zZyDJtFPMjs9eJ6QWb08SYpBsGQ2jVBVTXkujx3+/ynuOTRxjkkrMpfbqDW3GEqQf7uNRJVdYYHkpOvWtrz/uO7CO X-Gm-Message-State: AOJu0YwSUpTHmL6CQRHhC1976Jyo10wkWQYK+IJBNDbEV1PsJAa8yLlx 5IGY/r9tw92ygeXobuHhNfvg+tVXslIr3A4fCPWdEjLkAvYAGdB7 X-Google-Smtp-Source: AGHT+IHgTaUdNjnFlceuqDZQb86IcFDSmpZVDJyq9iZqJozpl3uONt9e5qvEXl/03kBUwqlpGmD+xQ== X-Received: by 2002:a17:90b:3ec6:b0:2c7:e420:a0ec with SMTP id 98e67ed59e1d1-2c7e420a3f5mr3603638a91.0.1718914823251; Thu, 20 Jun 2024 13:20:23 -0700 (PDT) Received: from localhost ([216.228.127.128]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c819dcc704sm81988a91.47.2024.06.20.13.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 13:20:22 -0700 (PDT) Date: Thu, 20 Jun 2024 13:20:20 -0700 From: Yury Norov To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, "David S. Miller" , "H. Peter Anvin" , "James E.J. Bottomley" , "K. Y. Srinivasan" , "Md. Haris Iqbal" , Akinobu Mita , Andrew Morton , Bjorn Andersson , Borislav Petkov , Chaitanya Kulkarni , Christian Brauner , Damien Le Moal , Dave Hansen , David Disseldorp , Edward Cree , Eric Dumazet , Fenghua Yu , Geert Uytterhoeven , Greg Kroah-Hartman , Gregory Greenman , Hans Verkuil , Hans de Goede , Hugh Dickins , Ingo Molnar , Jakub Kicinski , Jaroslav Kysela , Jason Gunthorpe , Jens Axboe , Jiri Pirko , Jiri Slaby , Kalle Valo , Karsten Graul , Karsten Keil , Kees Cook , Leon Romanovsky , Mark Rutland , Martin Habets , Mauro Carvalho Chehab , Michael Ellerman , Michal Simek , Nicholas Piggin , Oliver Neukum , Paolo Abeni , Paolo Bonzini , Peter Zijlstra , Ping-Ke Shih , Rich Felker , Rob Herring , Robin Murphy , Sean Christopherson , Shuai Xue , Stanislaw Gruszka , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , Valentin Schneider , Vitaly Kuznetsov , Wenjia Zhang , Will Deacon , Yoshinori Sato , 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 , Bart Van Assche , Jan Kara , Matthew Wilcox , Mirsad Todorovac , Rasmus Villemoes , Sergey Shtylyov Subject: Re: [PATCH v4 00/40] lib/find: add atomic find_bit() primitives Message-ID: References: <20240620175703.605111-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: linux-m68k@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Jun 20, 2024 at 12:26:18PM -0700, Linus Torvalds wrote: > On Thu, 20 Jun 2024 at 11:32, Yury Norov 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.