Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1574953pxb; Tue, 8 Feb 2022 22:48:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLNKJkWJw41ObAF4/gFswyXyXHH3SoswF2OkIkOG3bRsOAbxPan7+0Th3hs3VJ8B3LOeUG X-Received: by 2002:a17:90b:4c91:: with SMTP id my17mr971959pjb.221.1644389337312; Tue, 08 Feb 2022 22:48:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644389337; cv=none; d=google.com; s=arc-20160816; b=xH6qc0CYeXlQsFUG7Zo66GKYU1cgTJ+9tlpT6wpdMU+Kj+UOaXJkcmsT/Mkbo/mZzt 1YM3XsamIeVxBpmQsAuhTB1g114VWiLzTlzykw7NIuBFg6qjiDn3f3N3d6d2oHyUEOS9 +Pu5pEN1XVDefJe4wttabmknndmMgmtlcKqhEUWcKzWWFe8ueIUHNYUI4caRuI7aAn4Z LujbfBnP/qvn3RA2Pv2fpH1iVXNCZCRBJUlborpvoidevCb1VQVrY+a7VKhAWzqpKr82 8/SMiOLofMCY1IlTS9kAM2/DF3EXM4ZvCBZMxWGsc/8bKzxS5s9gqPi9OkFG8eVXWE8n w0aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wW5v18SsFr9UFGcEVFzDWXiJLXGqG2TS6A5yFHIl6Jc=; b=Gspp02i0yH7kBFrCAPCTlMmmUdYuz1wYGHowmxBADQMdQxefRU+qTje+mniTVTqb/o 6WBwVXQQH38/UZ04JESPhlvMFUs2EAMnDM/nQ0v8MEr7/SKUf0TIoLVD5y7YU8aGid2I n92hlAlXu4ECQPS/GYO5EXCaAgYkFXH/Mn/4D0FTaI7CopEv2bdJkgH2IaZVDmqjY8Dy Nfp48Ht7v4eitR0ZyjDJwazg/9k9K9k7jeIAykPucEM8XkdvSsVTjR5R+Ptdqfl9dl/3 qcmgdsxDlE89CnAyQv3eZG1gupbWOJAJ+ceLxYRTt2gKsxmoD3pes3ikFBZhGFulUlGY JyMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=lauEYb3m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j5si208031plr.24.2022.02.08.22.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 22:48:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=lauEYb3m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D7CA3E00FA57; Tue, 8 Feb 2022 22:17:25 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357302AbiBHNVS (ORCPT + 99 others); Tue, 8 Feb 2022 08:21:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359692AbiBHMwn (ORCPT ); Tue, 8 Feb 2022 07:52:43 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2178CC03FECA for ; Tue, 8 Feb 2022 04:52:43 -0800 (PST) Received: from zn.tnic (dslb-088-067-221-104.088.067.pools.vodafone-ip.de [88.67.221.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 8C4F41EC02B9; Tue, 8 Feb 2022 13:52:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1644324757; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=wW5v18SsFr9UFGcEVFzDWXiJLXGqG2TS6A5yFHIl6Jc=; b=lauEYb3mkpYVOjoKl82iGb4BxW8WhTexv0OYMU0Bi1UGmkaqXeONSkaTS7vb3qNqIYHZgA 1r8h0Aw0NO0LejTu36v1B2nacn2kHrlOm20OtnkjRPmbfGwFFDP2ISJIlEPWuHf9WS8fqX KuM9pm/0RJSI/s2NmzqvIgDwEiDfKLI= Date: Tue, 8 Feb 2022 13:52:32 +0100 From: Borislav Petkov To: Hugh Dickins Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, x86@kernel.org Subject: Re: x86: should clear_user() have alternatives? Message-ID: References: <2f5ca5e4-e250-a41c-11fb-a7f4ebc7e1c9@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <2f5ca5e4-e250-a41c-11fb-a7f4ebc7e1c9@google.com> X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Hugh, On Mon, Feb 07, 2022 at 09:45:36PM -0800, Hugh Dickins wrote: > I realize that dd'ing from /dev/zero to /dev/null, and sparse files on > tmpfs, are not prime candidates for optimization; and I've no idea how > much clear_user() normally gets used for long clears. Right, we usually don't take such "optimizations" because the folks who send them always come up with either microbenchmarks or only test on a single machine. > If I were capable of compiler asm, with alternatives, and knew at what > length ERMS becomes advantageous when clearing, I would be sending you > a proper patch. As it is, I'm hoping to tempt someone else to do the > work! Or reject it as too niche to bother with. Yap, looking at arch/x86/lib/clear_page_64.S - that's straight-forward asm without special-cases noodles like __copy_user_nocache, for example, so I wouldn't be opposed to someone - remodelling it so that you can have clear_user* variants there too, with the length supplied so that you can call a common function with arbitrary length and clear_page* can call it too. And then call them in a clear_user() version just like the clear_page() one which selects the proper target based on CPU feature flags. - testing this on bunch of modern machines with, say, a kernel build or some sensible benchmark so that we at least have some coverage If the numbers are worth it - and judging by your quick testing above they should be - then I don't mind taking that at all. If only someone would have the time and diligence to do it properly... :-) Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette