From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f49.google.com (mail-yx1-f49.google.com [74.125.224.49]) (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 B688928369D for ; Mon, 24 Nov 2025 14:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763996335; cv=none; b=T7LmlkJFvovHhQZQWW5LNsmNep36whS1T3aPk3bkxkvBmVsahqZFIFl8O+g9hAnzuCrrOcYin0Zg+9c7YqSzE0X1Y0FnHw9+Dl+9rt3r8hGnJGTSgZvMFGGolrMpd/kfjpIXWCVFLInBOA9jvNHh++vgE2S6MEEyYZcTQP2HJUA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763996335; c=relaxed/simple; bh=teRdMOgHWlpryFjttosenctGGBx0Ii3jBLHMKQW7laQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=INplHmdiZ+MUDFqF3WTTMu6bWfD8IbCKNAVZ1QqhKndJOZZKiH6LZIuUEJCHqSw6H1Hccjdrmol2j/fo5Ca6B3YkWYBc3Rnpb9AiPeQXTz4GPBXhn4meWsstZ6PCBC/B6z11OF1kWmeuVb4TMerJglVCRhXs1eLnql67WgA0B8w= 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=Yb0nvSXy; arc=none smtp.client-ip=74.125.224.49 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="Yb0nvSXy" Received: by mail-yx1-f49.google.com with SMTP id 956f58d0204a3-63e16fbdd50so3913188d50.2 for ; Mon, 24 Nov 2025 06:58:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763996333; x=1764601133; darn=vger.kernel.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=breoKq2LZ9mN5PHYIXVILrAjUh1AgBL35CDbLh6WqeA=; b=Yb0nvSXy3vS1o2K0hWhBGMM+ofd3/hXKfrAIsuedBPcwTkg2SyI/qS/o+DvXYgbA7N aEDoFcqaaDh9ZyAt8uZ4Xy31S6b0eqmPn8tG7WlndKjjaQastfu1dbe1gHPt5kdYjdoh cfZFRT08j7lvKvD7L9kvThBJKZ+pSNVZCRTgQ1akTDDfPSc567ME56kUek4PUnFxbh8i /yf+hQphClElwyvowpwL21tEfqDjgBiggbuZhTZnScXRybCQODiRphd0hsQLC8AWwfap S/OA3YEKpuOW38H+TjjRfYcpKVhOTYINPz6+bJpUralOBsUz975CAryeGOAFt7RyfzmH 7sZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763996333; x=1764601133; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=breoKq2LZ9mN5PHYIXVILrAjUh1AgBL35CDbLh6WqeA=; b=dxv1qBa/PPigRxsbDKdD3NrC4PrwgD5hlW5pDSDxjjb7Xqgiajs8ftGzLSwVO6ZJWQ kJ79b8X4qEPmzl4T5YIb6CL/1Q8rBW4NusEqFHRROuaSx9/VFPzq3LVx6GFdgF5BrVQk RGYpqMYUWdfEfjlc7mlZGweu+L4/bkPEEhcmFCPV83jzYH3C8ELF19QaHEtvtZS+rSSU YVb+KyZKBy/ga2MhOsXgqogdwvv35+PJAJISSezVFDPxT5DohxJnzI4xKJAgHMOHbZq1 2sQL2nkff/2hvGUjh8Rsjs3i4VJQHypTFEktIDnlUF6ou9Cjzh1KD4GmntBPH7NRknSW Buuw== X-Gm-Message-State: AOJu0YzA3yo+Cbdtcg6cx+hzyL39fZrJRsCF5JIPOkq/gWb8X1CY2fGQ J6U7oYNTRegamYX8IvrbiknoQ/Hk0cxm9/GnI/tdIjnZKgErmPgb7P28FgD85A== X-Gm-Gg: ASbGncsjMqCm956cCLZ3fJOfQSY/l6hNfzjx6ZE04ZP0DwQpiagDDI+dYrjoH567+Iz 1BdZsyW5G8dxJLX1UY96PK4AmqEEypkGL8gZLkJR8c1sp+XXHfTSbFbZ+6utwu8l4qphMtN0LZF 2BKU4E8DS1Ff6bNPkeuCularLgD8i209e5KUY5Jiu/h0ajYbTVl6n7Sg1+PDUVTu5K+v+iNRlsY 1sa6zSecTEW7xfDGlDIZCymQSSPKfxtYIrS3crmMWGgvHKl2HGtosJWKxi8BEA4J6QcQypGaR0f TS5GGBjpynFxBmfbJGmnwWzz0JXfa85EdBP0xxAghis9Z+/2gH4an680zOc/3h8gxHuZUsG0OSO AATBQyE05NfmqJ6IwbSAkLalj9VAEmOGYF9xqAW+vwYQ/NAoMQ/lNR58ti+gNY13afuwmHU9Uxo TRNMsZDuH9JnU2ZyBpxF6qif23aki9aUEn2SDIZY9Fq68= X-Google-Smtp-Source: AGHT+IE8NTLVVHsbgY95uJtMxh03FAB+pmu6kquhb0L5JAQ9OBe2odi2l5l/dCk3Q8yv61zi+rDgqw== X-Received: by 2002:a05:690e:10d2:b0:641:f5bc:695f with SMTP id 956f58d0204a3-64302b3f9aemr6161693d50.75.1763996332755; Mon, 24 Nov 2025 06:58:52 -0800 (PST) Received: from localhost (c-73-105-0-253.hsd1.fl.comcast.net. [73.105.0.253]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-643259fd696sm391634d50.7.2025.11.24.06.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Nov 2025 06:58:52 -0800 (PST) Date: Mon, 24 Nov 2025 09:58:51 -0500 From: Yury Norov To: David Laight Cc: linux-kernel@vger.kernel.org, Borislav Petkov , Dave Hansen , Ingo Molnar , Thomas Gleixner , x86@kernel.org Subject: Re: [PATCH 01/44] x86/asm/bitops: Change the return type of variable__ffs() to unsigned int Message-ID: References: <20251119224140.8616-1-david.laight.linux@gmail.com> <20251119224140.8616-2-david.laight.linux@gmail.com> <20251120182909.522d58cc@pumpkin> <20251120211810.60f53cb7@pumpkin> Precedence: bulk X-Mailing-List: linux-kernel@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: <20251120211810.60f53cb7@pumpkin> On Thu, Nov 20, 2025 at 09:18:10PM +0000, David Laight wrote: > On Thu, 20 Nov 2025 13:33:11 -0500 > Yury Norov wrote: > > > On Thu, Nov 20, 2025 at 06:29:09PM +0000, David Laight wrote: > > > On Thu, 20 Nov 2025 10:54:01 -0500 > > > Yury Norov wrote: > > > > > > > On Wed, Nov 19, 2025 at 10:40:57PM +0000, david.laight.linux@gmail.com wrote: > > > > > From: David Laight > > > > > > > > > > The return type of variable__ffs() is currently 'unsigned long'. > > > > > This makes the x86 __ffs() be 'unsigned long' whereas the generic > > > > > version is 'unsigned int'. > > > > > > > > > > Similarly change variable_ffz() and ffz(). > > > > > > > > > > This may save some REX prefix on 64bit. > > > > > > > > > > Detected by some extra checks added to min_t() to detect possible > > > > > truncation of large values. > > > > > > > > > > Signed-off-by: David Laight > > > > > --- > > > > > arch/x86/include/asm/bitops.h | 18 +++++++----------- > > > > > 1 file changed, 7 insertions(+), 11 deletions(-) > > > > > > > > > > diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h > > > > > index c2ce213f2b9b..2e8a954d2e2d 100644 > > > > > --- a/arch/x86/include/asm/bitops.h > > > > > +++ b/arch/x86/include/asm/bitops.h > > > > > @@ -240,7 +240,7 @@ arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr) > > > > > variable_test_bit(nr, addr); > > > > > } > > > > > > > > > > -static __always_inline __attribute_const__ unsigned long variable__ffs(unsigned long word) > > > > > +static __always_inline __attribute_const__ unsigned int variable__ffs(unsigned long word) > > > > > > > > There's a mismatch with the generic ffs() in asm-generic/bitops/ffs.h. > > > > > > > > The generic_ffs() returns int. There is another variable__ffs() defined > > > > in arch/risk, also returning int. > > > > > > > > So I believe, the correct fix would be to switch x86 to int as well. > > > > And anyways, I believe this deserves a separate series. > > > > > > It is a single patch, do you want me to resend the patch on its own? > > > (With a different commit message) > > > > The patch looks wrong to me. All the flavors of ffs(), ffz() and > > others should have the same signature. > > I only changed 'long' to 'int', all the generic (and builtin) ones are 'int'. > So I'm not sure which difference you are talking about. > IIRC the __attribute_const__ just lets the compiler do CSE. All the versions of ffs(), ffz() and others should in the better world have the same signatures. This is unfortunately not what we have now. for __ffs() we've got signatures: RISCV: static __always_inline __attribute_const__ unsigned long variable__ffs(unsigned long word) x86: static __always_inline __attribute_const__ unsigned long variable__ffs(unsigned long word) Generic: static __always_inline __attribute_const__ unsigned int generic___ffs(unsigned long word) You're changing x86 implementation to match the generic one, but don't change RISCV, and this is wrong. Can you make them all matching, and check the same for ffz() please? This would require a small separate series, I guess. Moving forward, it would be nice to make all that helpers looking more unified across different arches and flavors. Although, out of scope of your series. Thanks, Yury