Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp425124img; Thu, 28 Feb 2019 01:45:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IbFSDpW+GZ2WfRDgkCce3HdTpNbTJdJOw/nphFmtSoHNeqwfD6dW+ZfJpKAmu4gDw5tSKc6 X-Received: by 2002:a65:4204:: with SMTP id c4mr7649442pgq.136.1551347121472; Thu, 28 Feb 2019 01:45:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551347121; cv=none; d=google.com; s=arc-20160816; b=VI+QeF24etmj2yddk+7ZhNkFjWIh3WPnu7Qr16phX+rvUl/IXNsS96gLgMqcokWFmA CSYuZAEq5ZrudNwtEL76aSZcbUNAPrTG9XSmj+hM5pWTjV06+6VquN2qXPCbHEpbjI+y 62bk9WEvmQLuD56/H4fCfyxXptFkQ0S/hxZE/jGMePkiJ+MlG4wgxX1pSJbMF0AVLqmZ LhUtvC2KAWD9OBBg317VYfwSkTPjtvsvYK184zteyQMpapQV3cV5knaYiG/YSRhv39Ji +x4dc89unnaNlLl2NsLycUE/FquHIpUleZuSYQmb+VwW+/Z8m4LSkzD6BblensBPM3rN yCHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=hmVqqkIuaRpOxFpQRZZp/ZZZRrKqSJXrAOIwDCjT8MM=; b=EbLjEXrFKJXeaJ3xvPg863GelO1XcE7krFVPVWPNmNpRe62xlC8YO/yzOzmet+niUo DrnE32pYp7k22ITmFZxgJ38DZXk+baGv2pmY3dH7Nys5BwIdJZitnjoJXAH+VBkUVfB1 XBzFTEa9LGPgmt/f1hesGXRqF5Mdf02CYDGQ1gaveZ990b38aNSpSk0bVIu1RUDbllRe KvVuqev4+8Cl/f0RQ3KmmypFYjk/G2QGEGJbqF2qiOnJTFFLaoZkTguAQgSozw/8bSqa py4Uid9IOW2CO8Un+YrQHBkpzLyAMv/IRkc+W8Sk3sG04gz3shMv3yuXdeL8kpP+iqqv uu5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=nsHDUH01; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8si12446961pgu.224.2019.02.28.01.45.05; Thu, 28 Feb 2019 01:45:21 -0800 (PST) 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=@nvidia.com header.s=n1 header.b=nsHDUH01; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732224AbfB1JnL (ORCPT + 99 others); Thu, 28 Feb 2019 04:43:11 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:14778 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725973AbfB1JnK (ORCPT ); Thu, 28 Feb 2019 04:43:10 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 28 Feb 2019 01:43:19 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 28 Feb 2019 01:43:10 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 28 Feb 2019 01:43:10 -0800 Received: from [10.24.230.224] (10.124.1.5) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 28 Feb 2019 09:43:06 +0000 Subject: Re: [PATCH] sched/cputime: Remove unnecessary assignment statement To: Peter Zijlstra CC: , , , , , , , , References: <1551248002-27303-1-git-send-email-ketanp@nvidia.com> <20190227103230.GM32494@hirez.programming.kicks-ass.net> From: Ketan Patil X-Nvconfidentiality: Public Message-ID: <9bce6378-2221-f358-dc97-f15ee7ab546b@nvidia.com> Date: Thu, 28 Feb 2019 15:12:13 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190227103230.GM32494@hirez.programming.kicks-ass.net> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL108.nvidia.com (172.18.146.13) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1551346999; bh=hmVqqkIuaRpOxFpQRZZp/ZZZRrKqSJXrAOIwDCjT8MM=; h=X-PGP-Universal:Subject:To:CC:References:From:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type: Content-Transfer-Encoding:Content-Language; b=nsHDUH01bim0Rq33rcGduYBI4N6fpqAJsfPmyDCe6eEk2SAmF2peGkVvsEgrwRTQW h+uWCqEWC6dAPhqGUTZ86uI2sDCdFSBbbG0rvETdCoL2o7g9CTjnPmVg1j8au5y/6a 3yRZ1/1+NnDPBbG9XGaIX3heRSN7tA1e7ZkcG2+GdSehPrsO0T7Gy1OpdiQ3G+4hp+ yIDOGPsdzIqWZu5elX24IvYmikjApah8S4ZZV+ygYlVddnxYB0xx5yT0XZ221dTM/0 prlrTxvTNnlpsv0YOkn0wcznGwO91c+ftW2C4blTH1IHtO8EUpSfLt70oC8AeWb4l1 fg6KfEtCgctKA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The coverity tool has detected this issue as an unused value, since the code assigns the value to utime variable and then after the jump, the value of utime again gets updated, hence the previous value is not at all useful and this patch removes that first assignment. On 27/02/19 4:02 PM, Peter Zijlstra wrote: > On Wed, Feb 27, 2019 at 11:43:22AM +0530, Ketan Patil wrote: >> The original code assigns the value from rtime to utime variable, >> and then jumps to the update label. And the value of utime is then >> updated, so the earlier value of utime is not used. Hence remove >> that unnecessary assignment statement. >> >> This fixes one of the coverity defects. > Why does coverity care? I like the way the code is now, it makes > conceptual sense. Removing that assignment makes the code harder to read > and less symmetric (see the utime case right below). > > Any sensible compiler will 'fix' this for us anyway. > >> Based on work by Ishan Mittal >> Signed-off-by: Ketan Patil >> --- >> kernel/sched/cputime.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c >> index ba4a143..ad64771 100644 >> --- a/kernel/sched/cputime.c >> +++ b/kernel/sched/cputime.c >> @@ -616,10 +616,8 @@ void cputime_adjust(struct task_cputime *curr, struct prev_cputime *prev, >> * Once a task gets some ticks, the monotonicy code at 'update:' >> * will ensure things converge to the observed ratio. >> */ >> - if (stime == 0) { >> - utime = rtime; >> + if (stime == 0) >> goto update; >> - } >> >> if (utime == 0) { >> stime = rtime;