Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5799120ybe; Tue, 17 Sep 2019 13:48:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJZYf6MI3i+ugWKaYD2Ej/fabPf7XSwCEcgkKGO8kEIXnjy5ApmkaGzVhnhO9wPw4/3zbZ X-Received: by 2002:a05:6402:1246:: with SMTP id l6mr6648671edw.213.1568753328081; Tue, 17 Sep 2019 13:48:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568753328; cv=none; d=google.com; s=arc-20160816; b=sfDBQrAraun33D6Mz9oUqnMnofO5iUZMp5d29SOrZyAKICEtLIElA7xUjtIQbHko00 SRAhKAYgvSnayopDPtRdu0LjmNSCJJNqgp2GMVK7Ca47WT4bSlW9ONAGcVu94g1QQ0MA gfDhEZxZ8Y2KQoOZfVw8b7nVL36o8ozTQYlEVFJZ1n89eQ6j7P5MPggtCsNnc0iVt7xc L3CPUDVp12K+nG04jYGaLaW7BolggAtTWaf9dSwe/evCZn2fJ94U0XTzCethDHdqvST8 0nAVh0RlBmdE/OLyphCKCCCH2u3DALXROmRw4sUIFjP3LcBuHblVoamUImnc0tAoHugv +RQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=UTaApOHQWYgneuGzZ7YNtvEevdvs1utVLoBKbHK1gYc=; b=fvpppvGWtb+q7l45oCrVZuv1inJ2/u4tZVzgXKdJi25ngSt3BLmKCoD5rbLuS730zj FkmeqIwhmddsUXnF8CqzAtkzsq5EWbBw2zPqK/nYyhvwiH9HtkyOI+7cxFAR9FgJgQ6y cp06dIiSQ1PWbDdZExKdJvn7f5N7v5ioXhausonq0KeGg41zcH+o/JHJrSyQpPbnVNpW xPUoQT0qGoS7sCeuiypE36wKzbvkUc09YTEJO8GHnwQ9xIjpJZSr74t0XKm0EmKy44nq rzsiqLhU2XSST4wT0U6ktUmoWUBcT8gHR6Amrdf7Qbcvx3iMebqE6JTSCaMKcOMCGJ9L 2UNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=dJLYKuAk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rk6si1752179ejb.129.2019.09.17.13.48.23; Tue, 17 Sep 2019 13:48:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=dJLYKuAk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729918AbfIQUpn (ORCPT + 99 others); Tue, 17 Sep 2019 16:45:43 -0400 Received: from mail-lj1-f172.google.com ([209.85.208.172]:34732 "EHLO mail-lj1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726668AbfIQUpn (ORCPT ); Tue, 17 Sep 2019 16:45:43 -0400 Received: by mail-lj1-f172.google.com with SMTP id h2so5006621ljk.1 for ; Tue, 17 Sep 2019 13:45:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UTaApOHQWYgneuGzZ7YNtvEevdvs1utVLoBKbHK1gYc=; b=dJLYKuAkBH0gzZVZ5XUTjdiwI6yU/P2WChCP/N72EQ2Jjw/TxbYhFEMt3oMsLrmAsQ sO9ViXYnECjpjc2F/0uAhTdcUXwf//dQw+raN4fOY8re5ShVjoy3PG1vK0CYyIyluosO q0/CbwDt7HWX9fUrgappPxJpagzsKuCP75+uY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UTaApOHQWYgneuGzZ7YNtvEevdvs1utVLoBKbHK1gYc=; b=CSJlvZxvF85Lm//Wy6864Qg2S0pn9n7IXvmJa0rQtqLb/OE6Onh1U9Ujm/noy3lhci Wanuc3M43PWavq0dOVOJ4DwSllWw6jACScAehbYdVQBwtn/5GYpL9AtE/6Vpb3YzxNi2 NkAKpj5eEFVmbZcFXrH/HvmD6KTSEam9iZbWSToNAC5Q7scHmRppn/W/EJgpW8xwYnyp ItiPVJ2+0gdPTSyP4lgFEYe+otd0Ex/mH69S+iNPKutB0ea7BoxzdUP3WBAIIFVWEWzv QdhpvQBO48nbrBYD3RmV61vBdKiM0t9A3/7rNmq9cuAFx3evrg/6yvg1uyAs2nXfJWPV BBlQ== X-Gm-Message-State: APjAAAXU7N9MQ1vEcv5LuNTUMk5ZuS6DOYGE95zMNRS3G5eGakiGORlX Md+Z+7Yl2jg2cEYu0kBAWdatieKWN4g= X-Received: by 2002:a2e:9a03:: with SMTP id o3mr155002lji.51.1568753138926; Tue, 17 Sep 2019 13:45:38 -0700 (PDT) Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com. [209.85.167.44]) by smtp.gmail.com with ESMTPSA id k13sm629827ljc.96.2019.09.17.13.45.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Sep 2019 13:45:37 -0700 (PDT) Received: by mail-lf1-f44.google.com with SMTP id u28so3951114lfc.5 for ; Tue, 17 Sep 2019 13:45:37 -0700 (PDT) X-Received: by 2002:ac2:47f8:: with SMTP id b24mr128474lfp.134.1568753137199; Tue, 17 Sep 2019 13:45:37 -0700 (PDT) MIME-Version: 1.0 References: <20190913072237.GA12381@zn.tnic> <20190917201021.evoxxj7vkcb45rpg@treble> In-Reply-To: <20190917201021.evoxxj7vkcb45rpg@treble> From: Linus Torvalds Date: Tue, 17 Sep 2019 13:45:20 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC] Improve memset To: Josh Poimboeuf Cc: Borislav Petkov , x86-ml , Andy Lutomirski , lkml Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 17, 2019 at 1:10 PM Josh Poimboeuf wrote: > > Could it instead do this? > > ALTERNATIVE_2("call memset_orig", > "call memset_rep", X86_FEATURE_REP_GOOD, > "rep; stosb", X86_FEATURE_ERMS) > > Then the "reverse alternatives" feature wouldn't be needed anyway. That sounds better, but I'm a bit nervous about the whole thing because who knows when the alternatives code itself internally uses memset() and then we have a nasty little chicken-and-egg problem. Also, for it to make sense to inline rep stosb, I think we also need to just make the calling conventions for the alternative calls be that they _don't_ clobber other registers than the usual rep ones (cx/di/si). Otherwise one big code generation advantage of inlining the thing just goes away. On the whole I get the feeling that this is all painful complexity and we shouldn't do it. At least not without some hard performance numbers for some huge improvement, which I don't think we've seen. Because I find the thing fascinating conceptually, but am not at all convinced I want to deal with the pain in practice ;) Linus