From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 449E32E7F39 for ; Mon, 30 Mar 2026 19:20:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774898419; cv=none; b=QhixilTt5QEuuyckzhqcm1cHuF3c418FokmpRE0eAAKouR91jnswwqlp6RpQvVVzLxRl/FfE2qXpkJlH1rVPHOCvfOP6KqR2IfWaJFtWx0Kz/C0km59RFD7B4su1l1X+Qc2no+kytCgSyqHHeZO/PExRNMuAWfaJQHmVrCJXL9c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774898419; c=relaxed/simple; bh=lE7Sa7opgA/ihjnItS7woBT6ZA7cA86MLmUYuqDWD28=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fN1ZfEL0mKgq7n6t7+c7+e8Q8/+ncmPd6izNvcBNT5+o46DhfNqhryfkN8a5+WOIBZPFpsnG7qwes8jBIsYA8aIGr3a4+bvE2OKI7QnnlY1k4vMhVuWG3lW/OdbD56mfB083kSSSCFgR3aVBGAIb+KzANoKpRnYB4TwkPJD68CA= 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=D8vmFOKE; arc=none smtp.client-ip=209.85.128.54 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="D8vmFOKE" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-48374014a77so58899415e9.3 for ; Mon, 30 Mar 2026 12:20:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774898417; x=1775503217; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=fA+ibonDXOxKR6O2pT/X3F40s5qgQ13OhpeNcIMNgyw=; b=D8vmFOKEr1e8HkmyCuth8Uzh19x6QQSk3FshAv2kWlbfo0yQEJHICAOv/oFvquJM9l AXVGXSkUQuMjSpnFKqVHG3pfwfP3LDZn+zRb2jyOnU1LLG3jXuvGP0aXtkYZ0vqpdUo9 WDiSulYskmReDH6Dl/Xcdk6qV++ITdAeOlonm8yiWzr2HKO6dRPX1utrOTpr519ADQ3B X6VClYLdLyV3f+mp7O6j7ERTr2NBcuoMbvDWHQGZc3DBohRL9dpQ7fYpvbE8M4gh+n5m /Unsmf3APaQ+d+7MtrZvUSoQWpclpnN40tPHV710DWFxO9MffRcOm/JNQDNfTeN0NF/y 7mqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774898417; x=1775503217; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fA+ibonDXOxKR6O2pT/X3F40s5qgQ13OhpeNcIMNgyw=; b=NA+iqbGnjH7FqBRKzQFUYZOhAMeIXahtRTshWBgahFh/0src+HY1bE42dBv6oO9hxZ 3lm+Im/L59S2sCrGRhu9dn/AKxaAuS2NNADTArkZbiA1hTO0HpZH6Q0hHnLcgbE7J+mc 9I/cMEPsKQvBoeCSR3T15OVIc27mAbttrVI+XVyiAmwjF6hjHLfrPx2nj48mZH05WTNa U+ltuK87S4DB4K4Wej19B1Z+imYaKIcQNWcCSWTt/zrE5opSINnDQTmtHGbwevUNUxYG wmvWfcCtl5dWrY08U4om7Ongtz/Pt/Y0gPP+IeA9iiCayqXvzAe2LfHeZwh6QF+yYr04 RSxA== X-Forwarded-Encrypted: i=1; AJvYcCUpgWAwEEnW32yaFyNJUAWbQ6z/ec1KP2B9pfpAWlMpt7YMKKRnnv9XDpBkizzQd/ikQx9mEiMEDv9q31k=@vger.kernel.org X-Gm-Message-State: AOJu0YwH49fuqeqayPED76dbbEXxRIn3ijZcAIokN8VlN7JGeutVcy0J YfLrVTun36CckkKOR33YI8QaX50uFVQp+wtlsJI7UcuFiBj4245sq6VT X-Gm-Gg: ATEYQzzsbU1ezX2DOpxtxY5zZZADLgQ4mma2rzzLmIimLLTl3J7IF1vezmNZC1vVLeL pgegLRLUpnB41s2uDHyDMxkaFCesYvg7CwiiaOUN1MCF4+SLsiKnpVcxPYEfKK8LIw8UtYt20Bg fzS0eEglmtSEPOIc2F3LJ2VhzA1FAst+5rjaNMw9KbfjyqSuYrVbhscQa5zqyCPbNAyQPa064GV mudDEp8NQK3ejcmMk+ISTkp8urHiMTK+LQDe06BZ5R/GfkR9v5cntZm8Nl5US8Klgc1FnN7Tt/k ZjeIlum9HVLWfuSbbjeXqWyPo3Ca+StOlp7FktjiS8K9jxBVjppGQictR5LMvTvrHnoPufLz4Kw e2kEULEDr1wFUhIireUvLkE4Xip4czY9/j9tojKSVD4RbpdrmbDHWgeNIiz+AKw+nB2MB8o0Fx+ 1VIURv8vaQPsgiN6W4vWbvhFc+xIs5pXRlN7APpXHw4k7YWJCdlXFCG9o44Alm X-Received: by 2002:a05:600c:4e15:b0:485:2ce2:4c87 with SMTP id 5b1f17b1804b1-48727d45881mr236397845e9.4.1774898416390; Mon, 30 Mar 2026 12:20:16 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48733c095dbsm132897065e9.0.2026.03.30.12.20.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2026 12:20:15 -0700 (PDT) Date: Mon, 30 Mar 2026 20:20:14 +0100 From: David Laight To: Andy Shevchenko Cc: Dave Hansen , Andrew Morton , Andy Shevchenko , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Uros Bizjak , linux-kernel@vger.kernel.org, Kees Cook , Linus Torvalds Subject: Re: [PATCH next] i386: Remove string functions that use 'rep scasb' Message-ID: <20260330202014.1eb6fc76@pumpkin> In-Reply-To: References: <20260327195747.89556-1-david.laight.linux@gmail.com> <2f763ca6-794e-4b5a-9b92-9a9cc8858cd2@intel.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 30 Mar 2026 20:21:41 +0300 Andy Shevchenko wrote: > On Mon, Mar 30, 2026 at 7:58=E2=80=AFPM Dave Hansen wrote: > > > > On 3/27/26 12:57, david.laight.linux@gmail.com wrote: =20 > > > The fixed overhead of all the 'rep xxx' instructions is rather more > > > that might expect. While 'rep movs' is getting better on more recent > > > CPU, the same is not true for 'rep scasb'. On my Zen-5 it has a > > > fixed overhead of 150 clocks and then takes 3 clocks for each byte. > > > I've not measured any Intel CPU, but the cost might be 'only' 40 + > > > 2n. =20 > > > > One measurement on a modern 64-bit CPU isn't super convincing to me. > > =20 > > > Remove the asm versions of strcat() strncat() strlen() memchr() > > > and memscan(), the generic C versions will be faster. > > > > > > It is quite likely that all these functions are slower than the gener= ic > > > code on pretty much all CPU since the 486. =20 > > > > This is rather handwavy for my taste. > > > > There seem to be two valid paths here: > > > > 1. We continue the "nobody cares about 32-bit" refrain. This removes a > > bunch of 32-bit-only code and complexity. If it causes a performance > > regression, we do not care much. > > 2. Someone makes _some_ kind of effort to test this on at least *one* > > 32-bit-only CPU to see if it does any harm. > > > > In other words, I'm not opposed to the patch, but the justification > > doesn't really work for me as written. =20 >=20 > I have Intel Quark at hand to test. But I need to know the > step-by-step instructions on what to do. >=20 I can run my test on a few 'older' systems, but I don't have anything Intel before Sandy bridge and only an AMD 'Excavator' (or similar). I do remember (a long time ago) getting my Athlon 700 to run a copy loop as fast as 'rep movl' - but the setup time was a lot worse. So I suspect that generation of cpu didn't have a large overhead. If I've read Agner's tables he gives a 40 clock setup to P-II onwards. I can give you the source of the test I've been using. David