Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp249392rdb; Sat, 30 Sep 2023 03:06:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESyMgeJqmgjUc2QGt0Zni3VqpEin6k66Kd16T2mxuab948TVQoY7LTDOgGxjLRdpWrNFwm X-Received: by 2002:a05:6a00:124a:b0:68e:380c:6b13 with SMTP id u10-20020a056a00124a00b0068e380c6b13mr7345847pfi.15.1696068406237; Sat, 30 Sep 2023 03:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696068406; cv=none; d=google.com; s=arc-20160816; b=q5ySKD8bZE/A3UGsp3u87X8rXmbG0dii/ySn47TNetk9UjYWZxzWslWtn3V9mhsD4c Y5MmpHTNwv6ERoiCRPJ5YSQjQo5bcfMpQ4X5iLx2ODQdEpc/+74j71PUxLb3a30Cbj9/ xy+mZipHQhteC1HCrt+G3MXwTvHgmM16+C6g5TC9TSC6jp190WbRprplOWHxo2PaUm6P Jqq6zSygP75lDnQYdlOsD9YPKoO8vC7h5g6GIzO1VbYd0O11AHkwsC9ohVw6bGz7pdz6 SwdS8CZwn9zb46zTgDtRUCKaXyIoz3uRi/7mKHLUcSYG+PEPawCm+6iw8/rvIjb8mvHa c0Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=5KCDwTuOHUzfyy6M2ox7/ZjT3TpJHZ7cY4TTkfYkpO0=; fh=BmRgMtnYMdpYVpWzRTPNb1LZHFjoletclFN9n5/oi1M=; b=Tzyz6+v5KiZa65wEJqggDH3pxJd3FdGmKZtk5GQT+Fl0X4+o0IWYsqLyUu/iZ5ZHSD feFUTKRPfbxlFl4i3veeBXuJkM2xX/55ozpeRiS9oT9UZ2Y7IXs6ftRQCRGsBlDWkddp GF65qIXf9WDzDQF3qx8k5WS3ImCgrzUxtJDWvBTjMgwWLi7Sf3JpRU1CUyXoJrzx3NJu rK5LN1JL+c6BTMZjRYossbWYM/XC5XPryua7+YObxq10j2IlV9Cg+00eGVfLlfMEPd0D JwwRMsmjhPRqLrx6VrLpmnV5U1Wf8mjef+bVqE1PpJfBYUA3QiRiCod2teSta3wx/U4K czuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shopee.com header.s=shopee.com header.b="Ezt/hSgm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=shopee.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h2-20020a056a00230200b0068e390d86b4si24119964pfh.133.2023.09.30.03.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 03:06:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@shopee.com header.s=shopee.com header.b="Ezt/hSgm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=shopee.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C99F7805A790; Fri, 29 Sep 2023 04:56:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232964AbjI2L4j (ORCPT + 99 others); Fri, 29 Sep 2023 07:56:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjI2L4i (ORCPT ); Fri, 29 Sep 2023 07:56:38 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D2BE193 for ; Fri, 29 Sep 2023 04:56:36 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1c5bf7871dcso113900885ad.1 for ; Fri, 29 Sep 2023 04:56:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1695988596; x=1696593396; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=5KCDwTuOHUzfyy6M2ox7/ZjT3TpJHZ7cY4TTkfYkpO0=; b=Ezt/hSgmEh3GBuFMOpvES3UUfh+fw0L7kr/UJxOLXP5xwZpsaJG+L1/OYZX13tz6y8 FASpAudhihMxcvme1jsHXqpocGvBN09/9pPUzoBkLNAvy2a3HP0a+e3MB5u/SGmtXhlm 8D87s+FDp/JYaxvwbydcV6mqAO7oYr7nuMINoK0Io48uCULfdimAIGrIYECzeclmCUVv U21htIlgSmxApcCJNnjfys685u0ybOIGrWHEPAnAWKzacPqsNhVIYMle6WhlakVg9lsZ xvsOLV8/al06Fugjbm/swbsyT/8G6tD8UC/oKcw7/mszV6OCz+MaFTY/i/SssXrJ8ewA NSyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695988596; x=1696593396; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=5KCDwTuOHUzfyy6M2ox7/ZjT3TpJHZ7cY4TTkfYkpO0=; b=LrE2ggcAGnMTjG/bHP+3A7WxJBd1P2/w/gC6/36DeEA0g+maFxi5DuCq3DRaotFmQP eGEJ+is+Ter/zJPlUFuDXTpE261BHNhg4DayRJf+D3ltxOYVKaNhCjinnbwx/JndiwIq 8w3VOihlKw8fW3DxP0SN4PorUFtpwM8ooqhVyW1cMYaCZFcfE2fOp3GT/RbGQbKV1SVo zHWrky4417bDSiWBUWZkd/8Kmi2Qs7jWRnH6bTSq1Sf4ivoDKGgJNNDowpsXKZyTEd+J g1i3JYgTzZ68w9JSLkZGZ4Dxe9UmgGzbAtcZbNyfAjLwnRVDvIQrww146H+mzQEQ0SQK 6emQ== X-Gm-Message-State: AOJu0YwlLjJOIgZvMOo1NxZodjjFd2xuHzAG43VA//aEYTw0uRmlwJUP BnMNR2EH++3Z8y/pECwu173t5A== X-Received: by 2002:a17:902:9b8e:b0:1c5:cc30:7329 with SMTP id y14-20020a1709029b8e00b001c5cc307329mr3397890plp.54.1695988596090; Fri, 29 Sep 2023 04:56:36 -0700 (PDT) Received: from [10.12.164.14] ([103.114.192.135]) by smtp.gmail.com with ESMTPSA id g14-20020a1709029f8e00b001a5fccab02dsm1103039plq.177.2023.09.29.04.56.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Sep 2023 04:56:35 -0700 (PDT) Message-ID: <67d55d76-a619-7b05-0e6c-1a097f702bbb@shopee.com> Date: Fri, 29 Sep 2023 19:56:30 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] sched: Filter root_task_group at the beginning To: Ingo Molnar Cc: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org References: <20230922094336.394865-1-haifeng.xu@shopee.com> From: Haifeng Xu In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 29 Sep 2023 04:56:41 -0700 (PDT) On 2023/9/29 05:03, Ingo Molnar wrote: > > * Haifeng Xu wrote: > >> We can't change the weight of the root cgroup. Let's handle >> root_task_group before doing any real work including acquiring >> the shares_mutex. >> >> Signed-off-by: Haifeng Xu >> --- >> kernel/sched/fair.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> index a80a73909dc2..1ac2df87e070 100644 >> --- a/kernel/sched/fair.c >> +++ b/kernel/sched/fair.c >> @@ -12594,6 +12594,9 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares) >> { >> int ret; >> >> + if (tg == &root_task_group) >> + return -EINVAL; >> + >> mutex_lock(&shares_mutex); >> if (tg_is_idle(tg)) >> ret = -EINVAL; > > So what's the motivation, how common is this case? It's not common. The users of __sched_group_set_shares() are sched_group_set_idle() and sched_group_set_shares(). So I want to follow the way in sched_group_set_idle(). If so, we can remove the redundant checks in __sched_group_set_shares() because all users have filtered the root_task_group. > > Normally this should be a -EINVAL error code path, which sane user-space > presumably never conscisously tries to call in that fashion, right? Yes. > > It's not worth optimizing pathological cases, especially > since we check for the root CG inside __sched_group_set_shares() > already: > > /* > * We can't change the weight of the root cgroup. > */ > if (!tg->se[0]) > return -EINVAL; > > > Thanks, > > Ingo