Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5390399rwd; Mon, 12 Jun 2023 04:35:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6l7kqFb8+n2Vas+yThu/7KbJYqJy7aBR9m93otph3zK8s08gDaDXo9E9n8x7EjzlwxtxJz X-Received: by 2002:a17:907:9307:b0:974:2169:5f81 with SMTP id bu7-20020a170907930700b0097421695f81mr9396962ejc.22.1686569755533; Mon, 12 Jun 2023 04:35:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686569755; cv=none; d=google.com; s=arc-20160816; b=m4h28243siEJ0P8zlntMS8SoMeA2Xc2t8dva2lpLqY99mYEGGeqKnlNujPz85k7pjJ xRq5gB+e8SwMmNqgCdORrDoIL3tIloeooQiSluLl8u7qNNsF4ELX4B+x7daeVLACk5Ya m/O5slzDq1CuV3zUZDEMoxF/ZLgdWJWM5cRuQdu4K+aawd+h0oysdjEMlnFpnawiElWL qzWbF/ih1Q95XmLk9jiPHZb8iQzD/gn6qme9WK4Yz/sOcU3z1dJ+qCzLpNMhuQ3iC91n omf0q+AUV0SsY6kS+n1Iyn6+ydaRgigz1wRTB+K9WoplEW2uwQTlJYtRWqyNcaJ8MF3M 0mtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=vn9XmzFCfAP4xk0kJ7qaLU2v0x0cmbrEQEPzoMusjqE=; b=SKert6AE19V3eI/tajyt4S+x9PWBTS2RXsRCgviC4g9ucaDyCiytvadKOCyuuHyaV3 BTM6YzR+OJgevuqFatDoyoOkfJjAye9TNSJ27uF47YD5rLA0f5UZJUvLCpYx1a5EE2KE npX9Ub4QfkZyii2giswIWdDCjv2Eh4vcEUEslg9Jsk+7n0l2WzAaduPGvjyhtJjgzvSK ot6YVxGG64HZl7AOFhaj7crkkRFvYFAaIHa9+p/FWoMBSjTMVub7fGX9Lux2nPJfEvF9 Q4ldSiIG+/RSCRXhnh5vxxHRS9XVpyCXwkevHsV1cM3SdT0HqmQdtMIUAs/M01FZYzg6 mNTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LLFRwbzI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n8-20020a1709067b4800b0096f739c478asi5347303ejo.642.2023.06.12.04.35.30; Mon, 12 Jun 2023 04:35:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LLFRwbzI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234835AbjFLKgk (ORCPT + 99 others); Mon, 12 Jun 2023 06:36:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229777AbjFLKgX (ORCPT ); Mon, 12 Jun 2023 06:36:23 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DF03A262 for ; Mon, 12 Jun 2023 03:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686564935; 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: in-reply-to:in-reply-to:references:references; bh=vn9XmzFCfAP4xk0kJ7qaLU2v0x0cmbrEQEPzoMusjqE=; b=LLFRwbzI7jxBGQsGpxC9vFmJ+zHf4Zs18kErS/H+NoDlg2KYdKNcHEvh0ptx4U3P/3/9zl wgLJ9KuKi1FxLX5Ko8BVKpwva8iCnOPYuoIUF9iu5/qktHW/3ug9YR6EpaIzKVZ+rGkfpg m+sN0z5JQ28lPNEcverJX3PHEKBXb9s= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-112-HMtFKm6qNWm2KYly_1mb_A-1; Mon, 12 Jun 2023 06:15:26 -0400 X-MC-Unique: HMtFKm6qNWm2KYly_1mb_A-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3f7e6582938so80226315e9.0 for ; Mon, 12 Jun 2023 03:15:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686564925; x=1689156925; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vn9XmzFCfAP4xk0kJ7qaLU2v0x0cmbrEQEPzoMusjqE=; b=cb0dhrlDq0iVttsfk+XY2sStLoTXmTXoDSXSto/TAJxPJThbUqOqykSlnmiAEUH+Id 7LomjRCLq+Tb0O/szj68TWutdx6IIP2jl9KKZvpslXZuyIsQtJlLKiofOmr265fSuPsq vnOMYYdFI3roN/idSNlwD6h81v9p9iBpbgpm0m7QWZuhOE+HqaWHd+c/X3oJnb1wTtVh iJWDOMXlmmY1k2B3BFDwverKNMgeVZirJeFJu86HIISFqFuLzA41+S59wxfLesR16LUO HF+qNdz86jNcWipSVIe3chT5NN8tdaiRrXQhfVjzZS076lQFNNjdHK/giE5BpVeFWf0M E5ZA== X-Gm-Message-State: AC+VfDzDrtJzEyz8hybP4+JbOBYzjb9jW4wGCCtO6pnmWwHFp98e4mkZ 3firpS/ymTtuQDAm+bjOKz6/qGxg9K/hm4CUyqnK6ZEgw7XcrOko9WX7QXxZjiZ+7j1JrP86rye cs73ueFN3zt2ofAoAsYbes4VC X-Received: by 2002:a7b:c40b:0:b0:3f4:447d:f74a with SMTP id k11-20020a7bc40b000000b003f4447df74amr7155824wmi.26.1686564924882; Mon, 12 Jun 2023 03:15:24 -0700 (PDT) X-Received: by 2002:a7b:c40b:0:b0:3f4:447d:f74a with SMTP id k11-20020a7bc40b000000b003f4447df74amr7155808wmi.26.1686564924605; Mon, 12 Jun 2023 03:15:24 -0700 (PDT) Received: from vschneid.remote.csb ([154.57.232.159]) by smtp.gmail.com with ESMTPSA id n5-20020a05600c294500b003f801c12c58sm10846852wmd.43.2023.06.12.03.15.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 03:15:24 -0700 (PDT) From: Valentin Schneider To: Li zeming , mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com Cc: linux-kernel@vger.kernel.org, Li zeming Subject: Re: [PATCH] sched: core: Simplify cpuset_cpumask_can_shrink() In-Reply-To: <20230518203416.3323-1-zeming@nfschina.com> References: <20230518203416.3323-1-zeming@nfschina.com> Date: Mon, 12 Jun 2023 11:15:23 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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 On 19/05/23 04:34, Li zeming wrote: > Remove useless intermediate variable "ret" and its initialization. > Directly return dl_cpuset_cpumask_can_shrink() result. > FWIW, this sort of intermediate variable can and will be optimized away by the compiler. It's pretty obvious to see in the objdump (GCC 13.1): before/core.o: mainline core.o after/core.o: patched core.o $ gdb -batch -ex 'disassemble cpuset_cpumask_can_shrink' before/core.o Dump of assembler code for function cpuset_cpumask_can_shrink: 0x000000000000b260 <+0>: endbr64 0x000000000000b264 <+4>: cmpq $0x0,(%rdi) 0x000000000000b268 <+8>: jne 0xb274 0x000000000000b26a <+10>: mov $0x1,%eax 0x000000000000b26f <+15>: jmpq 0xb274 0x000000000000b274 <+20>: jmpq 0xb279 $ diff <(gdb -batch -ex 'disassemble cpuset_cpumask_can_shrink' before/core.o) \ <(gdb -batch -ex 'disassemble cpuset_cpumask_can_shrink' after/core.o) Generally I think it's good to not be afraid to use intermediate variables if they improve readability, even if they have only one use (e.g. as parameter to a function with many arguments / long expressions used as parameters). In this case though, the intermediate variable really doesn't do much for readability :-) Reviewed-by: Valentin Schneider > Signed-off-by: Li zeming > --- > kernel/sched/core.c | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index a66960da3f5c..f3f2ece26291 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -9273,14 +9273,10 @@ void __init init_idle(struct task_struct *idle, int cpu) > int cpuset_cpumask_can_shrink(const struct cpumask *cur, > const struct cpumask *trial) > { > - int ret = 1; > - > if (cpumask_empty(cur)) > - return ret; > - > - ret = dl_cpuset_cpumask_can_shrink(cur, trial); > + return 1; > > - return ret; > + return dl_cpuset_cpumask_can_shrink(cur, trial); > } > > int task_can_attach(struct task_struct *p, > -- > 2.18.2