Received: by 10.213.65.68 with SMTP id h4csp850919imn; Tue, 27 Mar 2018 09:57:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx488zp/4mHxTVOEq1QJ23Ifi/ejDrxv+6y7rTvnfKT0eF8b9WD749fEpA1su+p3JLNbzmRMQ X-Received: by 10.99.105.138 with SMTP id e132mr48501pgc.407.1522169822341; Tue, 27 Mar 2018 09:57:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522169822; cv=none; d=google.com; s=arc-20160816; b=qBHxSo0/lYvfC3LFO6gfDf/PUyP3CS545KOYxDCD0RUb7A5NJDk5BUWLEz1ZJlOfAu aguldHi9n0Pf74m6FRjvSXk55v2cv6+frMjCRoOy1BwvqLcCbc+NndFxdyfB8xQN+Aq3 IPVU9+N2RXamGZMyERo3bfYSBzAuyNhoTPHyHliR+Tj47rTnhqUGD7YXxEE7LQvKzMtU stsxHAo3GMctcVGX5Ubfc+Hb1UdGeEb7gPa/1wsW8tQwcK5t23cPz0nFnplJsmz+Kayf Vuf3cLlvkyeAsBWiulHr5AHHPnFNIaeBL7mWApDa9ysRE3us4eDE4e25s42zfaFVksL8 LnfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XUP0Igxd/zufXR1IeJ8uT3OJcJsLePJsznDzH2JkcM4=; b=aMMBz2ntEtCYQGjMiBfMWdBlhJQ2/kW2bQuG4jBOd5sUVGSvahXI2UviJEvmxIVHEC RD/6d07CooITq1ODODh8RhNvcrBHSl457mOFkmd7BcRB1siI2YPRJAP5zegQhoI8/Vwg ytv6nbkhR1HCmI5Wf8ZSj3/r3Av+LqDrO99pGSSqNDpR3oX/j3mK49jP2ND59Be/pYWo UVtsjLhH5alMXyrXfCHUrx9eOw6CTNxircLDYVCvMgalM2dTFmPAFMCx3293IJfDYVbO 3pgKANg76n6B/86n2pJTq0eCxsRbKW993Ym8Pis8JZ2OZhHr3lhAqLsA4nR4eSA+Lxeo 2ofw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j25si1092255pgn.592.2018.03.27.09.56.47; Tue, 27 Mar 2018 09:57:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752712AbeC0QzH (ORCPT + 99 others); Tue, 27 Mar 2018 12:55:07 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48872 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932366AbeC0Ql5 (ORCPT ); Tue, 27 Mar 2018 12:41:57 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EC2ACF3A; Tue, 27 Mar 2018 16:41:55 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tejun Heo , "Peter Zijlstra (Intel)" Subject: [PATCH 4.15 043/105] sched, cgroup: Dont reject lower cpu.max on ancestors Date: Tue, 27 Mar 2018 18:27:23 +0200 Message-Id: <20180327162759.897978919@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162757.813009222@linuxfoundation.org> References: <20180327162757.813009222@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tejun Heo commit c53593e5cb693d59d9e8b64fb3a79436bf99c3b3 upstream. While adding cgroup2 interface for the cpu controller, 0d5936344f30 ("sched: Implement interface for cgroup unified hierarchy") forgot to update input validation and left it to reject cpu.max config if any descendant has set a higher value. cgroup2 officially supports delegation and a descendant must not be able to restrict what its ancestors can configure. For absolute limits such as cpu.max and memory.max, this means that the config at each level should only act as the upper limit at that level and shouldn't interfere with what other cgroups can configure. This patch updates config validation on cgroup2 so that the cpu controller follows the same convention. Signed-off-by: Tejun Heo Fixes: 0d5936344f30 ("sched: Implement interface for cgroup unified hierarchy") Acked-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org # v4.15+ Signed-off-by: Greg Kroah-Hartman --- kernel/sched/core.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6611,13 +6611,18 @@ static int tg_cfs_schedulable_down(struc parent_quota = parent_b->hierarchical_quota; /* - * Ensure max(child_quota) <= parent_quota, inherit when no + * Ensure max(child_quota) <= parent_quota. On cgroup2, + * always take the min. On cgroup1, only inherit when no * limit is set: */ - if (quota == RUNTIME_INF) - quota = parent_quota; - else if (parent_quota != RUNTIME_INF && quota > parent_quota) - return -EINVAL; + if (cgroup_subsys_on_dfl(cpu_cgrp_subsys)) { + quota = min(quota, parent_quota); + } else { + if (quota == RUNTIME_INF) + quota = parent_quota; + else if (parent_quota != RUNTIME_INF && quota > parent_quota) + return -EINVAL; + } } cfs_b->hierarchical_quota = quota;