Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp243592rdb; Mon, 22 Jan 2024 19:48:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEP3Sa1Hj/wUDjLH1S2Y6u5UVxGFXgOkKTXDYlYxjGVHhX+mwbb35sBQUVFNaZFLPCD94M/ X-Received: by 2002:a17:906:c088:b0:a23:339f:3313 with SMTP id f8-20020a170906c08800b00a23339f3313mr2987986ejz.55.1705981699362; Mon, 22 Jan 2024 19:48:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705981699; cv=pass; d=google.com; s=arc-20160816; b=sjUfCevwGahsUR7oxxL55uAybIX93nRscpoYoGU0UHLlJth7pU89hrlVBk02ZpKYtt YPLW/SDYwEcB9M9QGZpZBNyjZomcGsdbQspZBmpQRp1nZZtAON239yipNdZmTvbEMXJ/ y9NlP0nqADzsnCFuaCA8YM71wNroDzb3+7+8jWhcZwA8UAUP05CM1pGODUg06WL9bGAh RlqfOVX/Pyehadh28c/xOFvEuMYtfUucMMTxqR89vI0eLgtt/7gg96UWY9cfGzCaLVuG cLYGDqm83HC7ja6EZEI0J4G362jxAB57wwjTAHhcETH3OMnLuIREZdVK/0pWbrCRZJrA SztQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=jO1WIFhKyimeRi1ncgEPv8QF5ZcZOe2hpOuEIACKOeM=; fh=duoQCvjKx31JXbYGFTVYkA1tG2f7qT6P4Uewznqug2w=; b=ir0zAOY33HXlt1u8GFC9NfiNoZ/QwmoXfTLCZ9uWHmDtWxYCVNI1KViBFGmbEQSoXW 1Utv7Dw5gKWXgf+7ajVSveFIOoQ/D5aw6MNpSmR0sSIlk/dhvNVQBC6VGnRPo/OafN6P 2UjndWYYvGygnWoTlCdfPrXxM7Hu45tDridCvGSjNhd3MyQPMtcOT67DegjgpizrQ7kC diXAyjeVVHSMSHnrXqwHLrpemuDqdlTqYoBJ0NMQbsiXPyuGgRKfsryHKicakRYzxjzo /mvvRsV0rNwi/qQKTxxX2hAUpEAzHhaQxnWNW4Deu2BUWAsm2OFnpRmzBvYCFm5hyoys PpUQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-34691-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34691-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bl21-20020a170906c25500b00a27abacc97csi11461995ejb.371.2024.01.22.19.48.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 19:48:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34691-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-34691-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34691-linux.lists.archive=gmail.com@vger.kernel.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 22A511F271E3 for ; Tue, 23 Jan 2024 03:48:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EC2353B9; Tue, 23 Jan 2024 03:47:25 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1AB7539C for ; Tue, 23 Jan 2024 03:47:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705981644; cv=none; b=Nycr1aX+7ssu04ojPdXVMkU4hkMjj63BSNLND86GpT2/5s3p0iI3E909sicWUcaq4iZ494Ks+uokqzrh2aYsu+kLx5QwPBvjIO+nLPmuNh/UBcHWm+UIjRRiNaUQMtGARG+r+M9iB5Sm/w4GvZ359biXbL/ojSoVzG5xtparsts= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705981644; c=relaxed/simple; bh=Exm/fe0PGjVUjlzUbZS1DGXpWwSqBew2c8rReHa+hQE=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZtzdK3gR6cf0K2CjjGt8z8uy9Qvke4pSvgj+qShPEMEvdy1RNty11fmUuQiL5Xvi1RbQ30gM1FMJODd7pND6rdvgYTAL4GKSTQCZniC2uBaHUD/z3dUOqvflV6vshn2f+Rc2V8ANSuxeqwHRvvAkwbvsVdgy+7MNnfZjU93gvoU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B65A2C433F1; Tue, 23 Jan 2024 03:47:22 +0000 (UTC) Date: Mon, 22 Jan 2024 22:48:52 -0500 From: Steven Rostedt To: Yajun Deng Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] sched/fair: Return NULL when entity isn't a task in task_of() Message-ID: <20240122224852.6ab9b498@gandalf.local.home> In-Reply-To: <20231206063400.3206346-2-yajun.deng@linux.dev> References: <20231206063400.3206346-1-yajun.deng@linux.dev> <20231206063400.3206346-2-yajun.deng@linux.dev> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 6 Dec 2023 14:33:59 +0800 Yajun Deng wrote: > Before calling task_of(), we need to make sure that the entity is a task. > There is also a warning in task_of() if the entity isn't a task. That > means we need to check the entity twice. If the entity isn't a task, Does it really check it twice? Have you disassembled it to see if the code is any better? #define entity_is_task(se) (!se->my_q) static inline struct task_struct *task_of(struct sched_entity *se) { SCHED_WARN_ON(!entity_is_task(se)); return container_of(se, struct task_struct, se); } The above is a macro and a static inline, which means that the compiler should optimized out that second check. > return the task struct is meaningless. > > Return NULL when entity isn't a task in task_of(), and call task_of() > instead of entity_is_task() when we need a task_struct. I'm not against the change, as it could be considered a clean up. But it is up to the sched maintainers to decide if it's worth the churn. -- Steve > > Signed-off-by: Yajun Deng