Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp959825rdb; Fri, 16 Feb 2024 00:20:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVhyz7uOsx+ee7Xl/2Rf1RWCa7xDnYJrP7MTG8ssR5rRucy1G+SSiVCHy26Dzv+SPPobF+j5UqMCJxwqDCn2kP6Ta30k7AEWXYKp3Lflw== X-Google-Smtp-Source: AGHT+IF1apDfHQlku8oxUIywjjuqYTQ3FTOEgp1vqivN9/KwesOO2Cnxq2eeUvlJxKWGbCChY34C X-Received: by 2002:a17:902:f551:b0:1da:232:df50 with SMTP id h17-20020a170902f55100b001da0232df50mr5151821plf.6.1708071628270; Fri, 16 Feb 2024 00:20:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708071628; cv=pass; d=google.com; s=arc-20160816; b=I3jD/d6v3wzh8OaWkrXBc955ELP6i4ot2hMWikjj0UvadTnmT1KVocAE0sbq17YHku BcmwmYKsDlHSDkw5t/X8VMWvgDrniohwPByEWSM4Zxax9kj9mNWL1PaExAX8c1UowmS0 WTLbC7zmdHa1L51oZ13PhwPuTodxWNtoijrovUeAraFQ90PJ8MbrDlOBqF1yQ1vH54Y7 FKBhby5TNnbKA1CEn6a/XS6Aj80KHDy9EGz1TnyUVZ3Zh7/codMpdB76st5/Sp8x5F8S ksTMXEvtMxAxExdi1TXaGFTo68raSgTXRErhWrCXchDodq7HM2j3Cq7dqSeLjWpqZYMU SO6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=FIMHZLHgidom8xzo0JtT7bpMHA+BcXdFvKux27+zxKg=; fh=w3jTSx2JivnEcLzKOT0xAaB7PpbqWhrjf+ia0UJz/mM=; b=sWsEf/JHTc+1vFNrcNeiPG4xIyJEtbUwgq11qGELwxjGsI+82fmfxHgIZZU5bmgo53 Bf7gLCIvvLI0vmyUKGDS2iOSXXcBxpjFN2P/l4swZG0pMB3fZBIZDmop08BFMEAKyZAz HecBcXUmJAYRXyC/dCUFGhF5f8XYbmgkxQu+BdOhsmw1hFD4RE8k4CE4re9uuyQT/4FW 9GQr6XLqTQeHouGT2VuwblPTKFSzAwMT6/KiDBzw/GnBPFmJrzY/DIQE2CirI/C4besY BXsnxPnCV748BOip8Qd41M2PPFMOn0QSoLoHSsxQzKvOOHPcACGxWjAiS/u+ZMmL6VNO eKxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="S0ASr/SL"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-68218-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68218-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a21-20020a170902b59500b001db71b1752bsi2547083pls.424.2024.02.16.00.20.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 00:20:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68218-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="S0ASr/SL"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-68218-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68218-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 039DC28144F for ; Fri, 16 Feb 2024 08:20:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0F261B593; Fri, 16 Feb 2024 08:10:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="S0ASr/SL" Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 648BA17732 for ; Fri, 16 Feb 2024 08:10:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708071025; cv=none; b=JOZ2VqB0l3C7AuxJa5yIeE2jd1zxgvbd40f7T5n1dmwDw39zQ2hBITxsxIptWoOBzlu7b7aas4roKbJPz1/tjCuTbN069kWP7evOv1xQy1dlJgE0c9DBBN2qsRLyJrCioEBxS6F3Shy2ZmJMP4tdaSJJlRqtnuslDMIShcmuroY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708071025; c=relaxed/simple; bh=0uydNOdWxU499+hAnc9/iQNbM8NCAF4AuCCa9QpChxk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=jCgDuYxtfGl3Y8xHaNBkKI49fXWKplbpKKbkRhzCuVhV3m4Xt5u1zVQ1rnp/anJpcz0b3+rjBPR1Nm0PwKEqDBFodgUat0M9d075YDLqgf89mo0XyqxzaohyoE0jMBpkQj3KODyt20rz5wDq/amoqErxbpknI3hW83ySP0HMTFs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=S0ASr/SL; arc=none smtp.client-ip=209.85.215.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-5dbcfa0eb5dso1617280a12.3 for ; Fri, 16 Feb 2024 00:10:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708071023; x=1708675823; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=FIMHZLHgidom8xzo0JtT7bpMHA+BcXdFvKux27+zxKg=; b=S0ASr/SLEpJDapQlzFwaAUSzO4DqsJmn84GeQGRpBI8BeT4xE9v96pvgSCkax7brPi PMM+Qw6u/XjcSYmwWGN/0Xm0sqQDuWtd83/l7nL+CsDiTOFrtmF/LIQ6ZpaWdMYgcwjD qvtHgG9RbRDX8f5Yd0gu1tPiTgj+3VlvUyDCcK4LSxjWO4oUHe8JWbaBhyiavOOcilVY IiVii/wyQJRL/s2pmEl4FUlOf4BL8IoeH/XjV+xeWUrRRYbmjFUoO/WQfzFUqBYBWMGF +757jS3Ha7xq5Tj9xwttqOVXXufcL0Lp+JV5TrdoKqdE4U7myhsKQCBUhjdbdX6Rg6n2 FzYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708071023; x=1708675823; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FIMHZLHgidom8xzo0JtT7bpMHA+BcXdFvKux27+zxKg=; b=Ku3nAwHoAqxsTR3cKvuY8pDv7IvV2klKNF1lz/AUSLiESFApDx/wfpY1mB/6FV21UR hrQCPo9gXaVUyn9dNnkaUH56jdVbExB7XFnGY8iJEwe53TtLNIV9M2hQq6HJLUx85xyZ xDTVlPZv93X4MZ0QcPPoYq4o4d2tQRjtfGSVslQc7WKfdL8VdaQpK4CC10V+pCqWD0pD Pn7762cpIVdcPnpcvkajLedQxmnV5vRTqb3Sk9HtTY/x1SVS9IAu3VhOo8nCuMQhDfcD uuPvcTncaWsmtfINw/bLTLcestN315/IoGflXGK9SB2/0AoU02Moqtzm57PxsSdl3ezD 3VHw== X-Forwarded-Encrypted: i=1; AJvYcCWOrTThk4JlhSHLg6Td5razsVFsW7SSgf0xCplElkY7Ty0bdDkVCamxZxhfdQiYKnDlARbP5Ewd2J2fEpn5uXJv7Yh6E355LJ+4iSLj X-Gm-Message-State: AOJu0Yx6uuWqMxkvoYHPIbtylvKJutZu8mzmLn63BhlqCE7Ov6F5BxgS Y3ava/2+zikyRHAWHBmvIU+74fXEU8/u6UitI1wyfmnPfOyy0FUPe8Q/MO+dlU09thNH7xoIlef ve51jI9OYSG7GyV2GvA3i8QyxLpQxX0AlEftY2amfsyoU4la+ X-Received: by 2002:a05:6a21:670b:b0:19c:9b7b:66a with SMTP id wh11-20020a056a21670b00b0019c9b7b066amr4587380pzb.49.1708071023666; Fri, 16 Feb 2024 00:10:23 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240216061433.535522-1-sshegde@linux.ibm.com> In-Reply-To: <20240216061433.535522-1-sshegde@linux.ibm.com> From: Vincent Guittot Date: Fri, 16 Feb 2024 09:10:12 +0100 Message-ID: Subject: Re: [PATCH] sched: remove duplicate ifdefs To: Shrikanth Hegde Cc: mingo@kernel.org, peterz@infradead.org, sshegde@linux.vnet.ibm.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Fri, 16 Feb 2024 at 07:14, Shrikanth Hegde wrote: > > when a ifdef is used in the below manner, second one could be considered as > duplicate. > > ifdef DEFINE_A > ...code block... > ifdef DEFINE_A <-- This is a duplicate. > ...code block... > endif > else > ifndef DEFINE_A <-- This is also duplicate. > ...code block... > endif > endif > More details about the script and methods used to find these code > patterns are in cover letter of [1] > > In the scheduler code, there are two places where above pattern can be > observed. > Hunk1: Code is under check of CONFIG_UCLAMP_TASK in kernel/sched/core.c > from line 1353. Hence the same check at line 1795 is duplicate. > Hunk2: Minor update of comment. > Hunk3: Code is already under the check of CONFIG_SMP in > kernel/sched/fair.c from line 8591. Hence the same check in line 10185 > is a duplicate. > > No functional change is intended here. It only aims to improve code > readability. > > [1]:https://lore.kernel.org/all/20240118080326.13137-1-sshegde@linux.ibm.com/ > Signed-off-by: Shrikanth Hegde Reviewed-by: Vincent Guittot > --- > Changes since v2: > - Dropped RFC tag. > - Split the patches into individual from the series. > - Added more context to each Hunk for review. > > kernel/sched/core.c | 4 +--- > kernel/sched/fair.c | 2 -- > 2 files changed, 1 insertion(+), 5 deletions(-) > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 9116bcc90346..a76c7095f736 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -1792,7 +1792,6 @@ static void cpu_util_update_eff(struct cgroup_subsys_state *css); > #endif > > #ifdef CONFIG_SYSCTL > -#ifdef CONFIG_UCLAMP_TASK > #ifdef CONFIG_UCLAMP_TASK_GROUP > static void uclamp_update_root_tg(void) > { > @@ -1898,7 +1897,6 @@ static int sysctl_sched_uclamp_handler(struct ctl_table *table, int write, > return result; > } > #endif > -#endif > > static int uclamp_validate(struct task_struct *p, > const struct sched_attr *attr) > @@ -2065,7 +2063,7 @@ static void __init init_uclamp(void) > } > } > > -#else /* CONFIG_UCLAMP_TASK */ > +#else /* !CONFIG_UCLAMP_TASK */ > static inline void uclamp_rq_inc(struct rq *rq, struct task_struct *p) { } > static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p) { } > static inline int uclamp_validate(struct task_struct *p, > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 533547e3c90a..8e30e2bb77a0 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -10182,10 +10182,8 @@ static int idle_cpu_without(int cpu, struct task_struct *p) > * be computed and tested before calling idle_cpu_without(). > */ > > -#ifdef CONFIG_SMP > if (rq->ttwu_pending) > return 0; > -#endif > > return 1; > } > -- > 2.39.3 >