Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp975196rdb; Wed, 24 Jan 2024 00:22:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpKqUxJ4DpLF7JlOjJY7ZOY2cnw2SAH5OMYdWIww/CS2hMgvSGGvy39O6+ibWcgN7BuzcD X-Received: by 2002:a05:6a20:65af:b0:19c:4fb0:98ac with SMTP id p47-20020a056a2065af00b0019c4fb098acmr510945pzh.63.1706084545519; Wed, 24 Jan 2024 00:22:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706084545; cv=pass; d=google.com; s=arc-20160816; b=BwBGQdkj34AZS/MOyFU6nXMoLmRu+yLp2VDU6lmXed6kNd3m6p1bS9irL/yzX+KeDI SDZEWan2vbWnL7tGbgOSZXxXBuRgo56AB8X6rTzC2WXXvDVBavAsJqbUVOwabBXQdhGH DRDHEo2++NgAF09Qs47T3Nc3st8JKZxJirC0xw613XtAuIgTP3m/uKNmdlK/xAiLmyp0 feIYlWX3UVl4Ylol3114eLOMbR1WnRg1BgBNEFAF4pC/87B39lxBOjoYNUv+GLtUG7HY hS8DQIgA3zRvIgMliJ/Dsszho/wicv2YqyNRxY82d7CMcQWOTHcXNRGnIBfzoMeSXptE UIAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=p7MnCXuD88u4ilrUq6w2umVtP5EOnFHzJ9de6V4YW6Y=; fh=sDAS5yH919ZWef7C0L4X3+XTjsFrj+1rttBD4ZZ5GPk=; b=A712scfgg6wKiJnhaUqOVSVnx8cZcCKOGTHGNe2Wy7OC1tMkzDvRNvD79zDS88B+jb y3ZBZjIcxaXeiyewZZc0uDAr/fjtdtFqXUaBYWONQx4iVt7oDnfWUirlhD1Ug19iMIlE 2+V4lJgE5nLYQgtcuictCMwUnNH4eLiu64M6mSrysorQPrZ0/FmwroxTEmvSPJkjz2Ky 9xJtpriaRcmMYZJvpEAOGQ6er52EPGiN4rQDQoPL9XguBESJsdatFz5TNZCpsUNx11m3 AebZRNADWvOBPVm8kuzAEZ7t5uqLetFcFn4iODN/lSTm8ApGe58mAdbn+YWyYdyUgxLd fOUQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=biSQO9qu; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-36610-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36610-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x64-20020a636343000000b005cec867ecf0si11338382pgb.105.2024.01.24.00.22.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 00:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36610-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=biSQO9qu; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-36610-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36610-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A8642B28EAC for ; Wed, 24 Jan 2024 08:08:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8A3A1754C; Wed, 24 Jan 2024 08:08:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="biSQO9qu" Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (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 9A2E9171B8 for ; Wed, 24 Jan 2024 08:08:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706083703; cv=none; b=c5x26XGcwL1Erx6tNZBVVmXq61aKazEFY2NGX5HMus1aqt+HtFFS7WoqShKnpUfWhdBKD4n6c5CG45TpvJp6wYh0yLZPSaIpVqBRyAD6MuKg7/m1i6gpmA8IRrbyZHTq4IRzFTDQsdFF56WYFWP/cCRtXbcg8eGefpwTJHrawn8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706083703; c=relaxed/simple; bh=WuTsA4t0XYhq2dKRx42Ldt/2+0SYfNeIClfxM3tW+0o=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YGwBsV4T/4kYZbpUoV3EbOUtkYbPE6mjg4r6LGXAqV3uzugv7TZvCC42sHJqHr7corg2RNUeeg40dfxb5+PJSjJNRvAn4oIbQS9GdgdJCKJ1qA/UDfTlRzDSvIX16b4QJhlUTrNdllYMqrSpS7vtYXEwQ5H8Teb2UU/O7n9Rupc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=biSQO9qu; arc=none smtp.client-ip=95.215.58.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1706083696; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p7MnCXuD88u4ilrUq6w2umVtP5EOnFHzJ9de6V4YW6Y=; b=biSQO9quUA/W3uKimuqqoTTQdqD7VSMuYwRKATFiSecYDpujfoY8ORUJlpFmEBCeAV65Gb +YxKHFHs+5YQZUgxn7uDYSDL7qjiAX7igl/AH+qXmvk2z9u0oQqzDYlvNcroz6bGhKpPPP r5pWJ30N5Gz6ZBWuSBszBraU1MJIciw= Date: Wed, 24 Jan 2024 16:08:05 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v2 1/2] sched/fair: Return NULL when entity isn't a task in task_of() Content-Language: en-US To: Steven Rostedt 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 References: <20231206063400.3206346-1-yajun.deng@linux.dev> <20231206063400.3206346-2-yajun.deng@linux.dev> <20240122224852.6ab9b498@gandalf.local.home> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yajun Deng In-Reply-To: <20240122224852.6ab9b498@gandalf.local.home> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2024/1/23 11:48, Steven Rostedt wrote: > 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. Yes, the second check should be optimized. > >> 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. Return NULL in task_of() makes the code cleaner. > > -- Steve > > >> Signed-off-by: Yajun Deng