Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp229328pxf; Tue, 6 Apr 2021 20:30:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS8iIFD6RVTD7VZzUacx/nGkun/1ztCLdniz+GFQS25aeWmRKoPbV0nON3/h7hxlcFvUQY X-Received: by 2002:a5e:c117:: with SMTP id v23mr868855iol.54.1617766219414; Tue, 06 Apr 2021 20:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617766219; cv=none; d=google.com; s=arc-20160816; b=ELR9Re32gzejUxNyqboz/q/j2giXtQ6U5+AeH1opOD9UfFPsodX0F/ElFZkldEcbXe ybZuqzzq8HfaqTOUDa12VAXJoProqL+LEDJaYNZw64TgsTHCzp62ojtQpOFnI+rz8bSw XTz1UwrCCWG12CXj+hOgNlUR0EOBIvExwHzqwXpeJTkA4lZySpWrwUgTxYThYjiHLs7d 3X+bsz5+Nj3C5LbIvSWgCfhUjvVwkmBFFq/gZEn4P6bNkA25u6jEQQyboEVaPTo3LZ7Z vwp3j89kkUwFHrXjU4aHtYyBYeaTCkXE+Xendwga71OweLGavT9gSsKWNVxrZASz/z7Z NfeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=YXOWvNOAIfgi9gqBy5DvwnTrsEdHbB64uWkA3abilWU=; b=nsAnTVqsykp964Tp9Jn9sLp/XcRUoEeLNhfVDUq1SAEw5M3qydjd8gSrTQOav7RUxg Rok+vdDD5FGOCKxDLkCFWSQNvsbzCF+rPzSdwoc4wWbBdlGaNsDlzaEMWkz86pcs/MIj hbn/3utXMtLY7xPRkpDxTCpLXAhHQRIXoG4G+urJXIHmGcR3yosFfxf9EPqAKPw2GjVw 7kgkIE/1F2CSeUl7+CM5q0rltF8jCgibXv23n9g31o9pesysTga3BpvRph6xSbAEyoYP Oh6wqAomyu6POnpwDEHlLtvvhgZVVg7cSqYyYnFjDmNW++tg5Be6mSqrXPIpRM1x0ciO HOwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QLQkqzAe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g22si19808801iob.26.2021.04.06.20.30.07; Tue, 06 Apr 2021 20:30:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QLQkqzAe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233339AbhDFNgU (ORCPT + 99 others); Tue, 6 Apr 2021 09:36:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232777AbhDFNgN (ORCPT ); Tue, 6 Apr 2021 09:36:13 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 449CCC06174A; Tue, 6 Apr 2021 06:36:04 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id c3so14893173qkc.5; Tue, 06 Apr 2021 06:36:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=YXOWvNOAIfgi9gqBy5DvwnTrsEdHbB64uWkA3abilWU=; b=QLQkqzAeiYAjql/CBYeCXbnB9686oKnalJzTqApxbMhRQqeBZWrm69SrvTPBvXPGUz HnNDlwIuv8W4dZFeKPUTn/pS2aKrnF1F1vSjWvV3u4ttyPszRWoHhUmDbFxyKOEgAeoe FX1/ANr4FBT/9uIdb9Ge3vgwEu78kw4ErBowRW9guepBIvhhW+HZoI/yTUB5W4psNpJE QxRTWAyFVIHksYuoc/hP8xDpVTjs4qVrdgwQ6XCU/rx1JX6avFSVsN+HcMnLA5CMXzf/ 686ZRKvFNnk3jwGtO6UHZnqLYjYJmAJgQIZDYh0fNGuhbuWggvzXgfQnjOvZO1RtJFAT vUDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=YXOWvNOAIfgi9gqBy5DvwnTrsEdHbB64uWkA3abilWU=; b=kIlu24vdI5T6jtTlGN4SnwxIQxHvM3Ktb0g/SQIulC6ZOEym/dm+H4JZm/lLGWLxrN GBAWOcCjaST7/H5LggXgiuE88AhZ5qlyiKyfwvsWsxo2zaGcRrC1t247xWVMjIhUAlqq NWtPnjfTK0DXuczfXk2SOjqwier9ohajp60Lm4HjWMLCnLeCXYr243u7uVY9G/nwH1kX ImWEY0aIpzPPKC9Vj9OPZveYtumf76AyggBPulgZHVlVQf4lfdiZ2+Bk/ZjLFsRxRl0V K27DfxygiHQmJL8FUaRSPOa7WekV/qV9DYbVp4T0XnNIUoXAtUeZi4DNyYITutOmQNVu QF4Q== X-Gm-Message-State: AOAM5325M+eXBXKcON13NWozbso8ssC+9FdcYcMbdc1+7Ys3zHs2s0cN GAG95R21QEHqJRBQA/Awswc= X-Received: by 2002:a05:620a:c0d:: with SMTP id l13mr29020975qki.234.1617716163308; Tue, 06 Apr 2021 06:36:03 -0700 (PDT) Received: from localhost (dhcp-6c-ae-f6-dc-d8-61.cpe.echoes.net. [199.96.183.179]) by smtp.gmail.com with ESMTPSA id e2sm14550488qto.50.2021.04.06.06.36.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 06:36:02 -0700 (PDT) Sender: Tejun Heo Date: Tue, 6 Apr 2021 09:36:00 -0400 From: Tejun Heo To: Pavankumar Kondeti Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Zefan Li , Johannes Weiner , Quentin Perret , Wei Wang Subject: Re: [PATCH] cgroup: Relax restrictions on kernel threads moving out of root cpu cgroup Message-ID: References: <1617714261-18111-1-git-send-email-pkondeti@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1617714261-18111-1-git-send-email-pkondeti@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Tue, Apr 06, 2021 at 06:34:21PM +0530, Pavankumar Kondeti wrote: > In Android GKI, CONFIG_FAIR_GROUP_SCHED is enabled [1] to help prioritize > important work. Given that CPU shares of root cgroup can't be changed, > leaving the tasks inside root cgroup will give them higher share > compared to the other tasks inside important cgroups. This is mitigated > by moving all tasks inside root cgroup to a different cgroup after > Android is booted. However, there are many kernel tasks stuck in the > root cgroup after the boot. > > We see all kworker threads are in the root cpu cgroup. This is because, > tasks with PF_NO_SETAFFINITY flag set are forbidden from cgroup migration. > This restriction is in place to avoid kworkers getting moved to a cpuset > which conflicts with kworker affinity. Relax this restriction by explicitly > checking if the task is moving out of a cpuset cgroup. This allows kworkers > to be moved out root cpu cgroup when cpu and cpuset cgroup controllers > are mounted on different hierarchies. > > We also see kthreadd_task and any kernel thread created after the Android boot > also stuck in the root cgroup. The current code prevents kthreadd_task moving > out root cgroup to avoid the possibility of creating new RT kernel threads > inside a cgroup with no RT runtime allocated. Apply this restriction when tasks > are moving out of cpu cgroup under CONFIG_RT_GROUP_SCHED. This allows all > kernel threads to be moved out of root cpu cgroup if the kernel does not > enable RT group scheduling. The fundamental reason why those kthreads are in the root cgroup is because they're doing work on behalf of the entire system and their resource usages can't be attributed to any specific cgroup. What we want to do is accounting actual usages to the originating cgroups so that cpu cycles spent by kswapd is charged to the originating cgroups, however well we can define them, and then throttle the origin if the consumption is going over budget for that cgroup's allocation. This is how we already handle shared IOs. The problem with the proposed patch is that it breaks the logical organization of resource hierarchy in a way which hinders proper future solutions. If all you want is deprioritizing certain kworkers, please use workqueue attrs instead. Thanks. -- tejun