Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3301372pxk; Mon, 28 Sep 2020 13:45:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyW8uq5squeqP77CUmWpfnlEkQhuQQNTlGKnBxFhY6zWuxrUqXwEDMlCdgFoNJBAB+/e9Cp X-Received: by 2002:a17:907:417c:: with SMTP id oe20mr568189ejb.322.1601325909884; Mon, 28 Sep 2020 13:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601325909; cv=none; d=google.com; s=arc-20160816; b=ltdb3pZ74I+g0tSRLe1eqn8g9TlsjTnlDUfNPww5KYc3gzHx07wGeZqjLubrZUm492 BCTdTEFkM+FkaRlNrrZj+72UfVWbGhhP+uj3WSpGIKbsvh6QSNdjMCZHMoFSE0crW79y 6hOI4EWFx0pT+nbgZjJ3sFEdpLrBnKBQMxyHxv3EcKYPh/o2sNzlkebvfVUP+hgUhUQY SDsjelpizTHG8f08f4xm2zEqOiXMo9p3EKiU2C74XHLcJDZMZXZ5XtIrC/eQ0clpsLep wahcu91kKtyf3UHfyRJKuxTI8Aelhq+IAtyJ/wGeZ6unrq9DntV0EHLwxDgQLdPnjPoR oqqg== 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=JbsSO0zP4i+4+OZXhhTK0jpolLCqQxk8S7EHJu7e4UA=; b=QTMpV5fjsGForSjEtH8LjMcvRYbK9fr91H1okmCpQ928wdSCm6WktwvLXj6qeJhKjb BpznIbsTndGDXfoK4E0jPYebovh5lyoDybV2Q07MCz3YPRI2wPkqLSnLWJGHneosL83y W4w/7RM3WmHa2oF2ft21gGdiqsAVHqzLY0ID7aj8F+VFlwXZ4VgdKaLBaMk/lH0B1JQ7 ANLFZ2zzaXn08v/bQOHWqYINMhYWhT8+5/x0AYGBJUsPq+3VVEHCiKzXVLMDGNin1GnL V27CYI6VHPaIh5thqe5xCAc0IcVPdbouwtBfMwvBg7MhAhau24/U5chS8093DWRrbgTK JWqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="PDPtID/t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v16si1327304eds.222.2020.09.28.13.44.47; Mon, 28 Sep 2020 13:45:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="PDPtID/t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726839AbgI1Unu (ORCPT + 99 others); Mon, 28 Sep 2020 16:43:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726328AbgI1Unu (ORCPT ); Mon, 28 Sep 2020 16:43:50 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E461AC061755; Mon, 28 Sep 2020 13:43:49 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id f18so2230233pfa.10; Mon, 28 Sep 2020 13:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=JbsSO0zP4i+4+OZXhhTK0jpolLCqQxk8S7EHJu7e4UA=; b=PDPtID/tw5h9Kf0tijaIWL1aQgj5Ev/kQsnVA5MW5HyvGy6l0cEkT1QB3a80QCu0qh Jkt/6VyymU2TjzCEqhV990copDeC2Xrv4NZf7bkdEZ0HqNSzH5z//DbEU8VPDldfLOYn 6eFqwG9+0j18a6P4krLOC0iM9hNzYMIU+p/rmiyVAG8wf4DyXyZ5pBvQRM1gZ8Qn9LFJ cxLMSz+HM0cLL+ZDul71GO4p1oDe6Diepl8x/8pNYJo1OcKen34YbxcBtl5QP2oZ5g6R fl3ZZIQiUt9iQy9RBWWo0+G1a/pLYhGRKgwydJM7Z46IEhfW3IbUIs0+hep9dmNm2FoU sBNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JbsSO0zP4i+4+OZXhhTK0jpolLCqQxk8S7EHJu7e4UA=; b=F1oySCAy0nfgdkaf5nzmKKM+Mknhr5Xrz+5LP17fvdSv2xZwqWmJf4Cm1Gt0IBuQNd KXMTku6u3Qr9zP8Rui5KYEyjGum8Ijj+3K69dBx8iDBFpCzBf8D3eg5HaDPi25I6hARt Bbjgvj0bfY3pr99CWw3ngg9rub3c7aH0JSpXRjWBNH/XBLPPcBy2ecedJIRK8x7psrxs EF+HCCwB+mOhsIlT0HE2sz7aydnuorPX3X/mlnMq7KSyl1sAx3Qjb1OtfZ6cfpCNiIs/ tIfZFCjVVVoNmm9qCtPA/6cJZquqifqH+kbmQG5jk0mRbi3PjJXR97FldHm7WLgw90In evww== X-Gm-Message-State: AOAM532g+8C0DYcRp3+5tXSIMFtF9g2LWMA/KAQFoonyDVSxnYPZcHAe SIGZMRiOJNiUYdJGpqnVZPI= X-Received: by 2002:a62:1410:0:b029:13e:d13d:a129 with SMTP id 16-20020a6214100000b029013ed13da129mr994603pfu.17.1601325829273; Mon, 28 Sep 2020 13:43:49 -0700 (PDT) Received: from ubuntu-m3-large-x86 ([2604:1380:45e1:2200::1]) by smtp.gmail.com with ESMTPSA id i36sm2269309pgm.43.2020.09.28.13.43.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 13:43:48 -0700 (PDT) Date: Mon, 28 Sep 2020 13:43:46 -0700 From: Nathan Chancellor To: Lukas Bulwahn Cc: Balbir Singh , Thomas Gleixner , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, kernel-janitors@vger.kernel.org, linux-safety@lists.elisa.tech Subject: Re: [PATCH -next for tip:x86/pti] x86/tlb: drop unneeded local vars in enable_l1d_flush_for_task() Message-ID: <20200928204346.GA953199@ubuntu-m3-large-x86> References: <20200928124457.27289-1-lukas.bulwahn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200928124457.27289-1-lukas.bulwahn@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 28, 2020 at 02:44:57PM +0200, Lukas Bulwahn wrote: > Commit b6724f118d44 ("prctl: Hook L1D flushing in via prctl") checks the > validity for enable_l1d_flush_for_task() and introduces some superfluous > local variables for that implementation. > > make clang-analyzer on x86_64 tinyconfig caught my attention with: > > arch/x86/mm/tlb.c:332:2: warning: Value stored to 'cpu' is never read \ > [clang-analyzer-deadcode.DeadStores] > > Compilers will detect these superfluous local variables and assignment and > optimize this anyway. So, the resulting binary is identical before and > after this change. > > Simplify the code and remove superfluous local variables to make > clang-analyzer happy. > > No functional change. No change in binary with supported compilers. > > Signed-off-by: Lukas Bulwahn > --- Reviewed-by: Nathan Chancellor > applies cleanly on next-20200925 > > Balbir, please review and ack. > Thomas, please pick this minor non-urgent clean-up patch into the x86/pti > branch of tip as follow-up to: > https://lore.kernel.org/lkml/160026187842.15536.285514864386042510.tip-bot2@tip-bot2/ > > I quickly confirmed that the binary did not change with this change to the > source code; The hash of tlb.o remained the same before and after the change. > > So, in my setup: > md5sum tlb.o > 7c7e096bab0fd87bd2c8437d8c7dc3fa tlb.o > > linux-safety, please verify and validate this change. > > arch/x86/mm/tlb.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c > index 6b0f4c88b07c..90515c04d90a 100644 > --- a/arch/x86/mm/tlb.c > +++ b/arch/x86/mm/tlb.c > @@ -316,7 +316,7 @@ EXPORT_SYMBOL_GPL(leave_mm); > > int enable_l1d_flush_for_task(struct task_struct *tsk) > { > - int cpu, ret = 0, i; > + int i; > > /* > * Do not enable L1D_FLUSH_OUT if > @@ -329,7 +329,7 @@ int enable_l1d_flush_for_task(struct task_struct *tsk) > !static_cpu_has(X86_FEATURE_FLUSH_L1D)) > return -EINVAL; > > - cpu = get_cpu(); > + get_cpu(); > > for_each_cpu(i, &tsk->cpus_mask) { > if (cpu_data(i).smt_active == true) { > @@ -340,7 +340,7 @@ int enable_l1d_flush_for_task(struct task_struct *tsk) > > set_ti_thread_flag(&tsk->thread_info, TIF_SPEC_L1D_FLUSH); > put_cpu(); > - return ret; > + return 0; > } > > int disable_l1d_flush_for_task(struct task_struct *tsk) > -- > 2.17.1 >