From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EB53C47098 for ; Thu, 3 Jun 2021 21:25:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57A8960FE5 for ; Thu, 3 Jun 2021 21:25:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230220AbhFCV0p (ORCPT ); Thu, 3 Jun 2021 17:26:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40116 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230121AbhFCV0o (ORCPT ); Thu, 3 Jun 2021 17:26:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622755499; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=r7Nr9zyNvu4ZyjMH6h4XMEahwlMJwXbItTVRKJ/5iiE=; b=U30E1QRaSQhwd/pOsQEyimZByw2Dan3acssCKOoPfppbqubkfPGC37N58+Ow5dUZupcygy 34UnvEH5akh/eKeqULaEFArMruEHhHrITD+5ISFFZpHezdJRl5l6kpYnx77x+HRsnXUFlj 0cGRtDCi603lVyHtyqnIB0l8O6oUWhw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-454-fWZzddPbPKewv3al71-w-A-1; Thu, 03 Jun 2021 17:24:55 -0400 X-MC-Unique: fWZzddPbPKewv3al71-w-A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C47B80ED9B; Thu, 3 Jun 2021 21:24:54 +0000 (UTC) Received: from llong.com (ovpn-116-222.rdu2.redhat.com [10.10.116.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id A935150FA1; Thu, 3 Jun 2021 21:24:50 +0000 (UTC) From: Waiman Long To: Tejun Heo , Zefan Li , Johannes Weiner , Jonathan Corbet , Shuah Khan Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Andrew Morton , Roman Gushchin , Phil Auld , Peter Zijlstra , Juri Lelli , Waiman Long Subject: [PATCH 1/5] cgroup/cpuset: Don't call validate_change() for some flag changes Date: Thu, 3 Jun 2021 17:24:12 -0400 Message-Id: <20210603212416.25934-2-longman@redhat.com> In-Reply-To: <20210603212416.25934-1-longman@redhat.com> References: <20210603212416.25934-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The update_flag() is called with one flag bit change and without change in the various cpumasks in the cpuset. Moreover, not all changes in the flag bits are validated in validate_change(). In particular, the load balance flag and the two spread flags are not checked there. So there is no point in calling validate_change() if those flag bits change. Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index adb5190c4429..65ad6995ad77 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1891,7 +1891,7 @@ static void update_tasks_flags(struct cpuset *cs) * cs: the cpuset to update * turning_on: whether the flag is being set or cleared * - * Call with cpuset_mutex held. + * Call with cpuset_mutex held & cpumasks remain unchanged. */ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, @@ -1911,16 +1911,22 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, else clear_bit(bit, &trialcs->flags); - err = validate_change(cs, trialcs); - if (err < 0) - goto out; - balance_flag_changed = (is_sched_load_balance(cs) != is_sched_load_balance(trialcs)); spread_flag_changed = ((is_spread_slab(cs) != is_spread_slab(trialcs)) || (is_spread_page(cs) != is_spread_page(trialcs))); + /* + * validate_change() doesn't validate changes in load balance + * and spread flags. + */ + if (!balance_flag_changed && !spread_flag_changed) { + err = validate_change(cs, trialcs); + if (err < 0) + goto out; + } + spin_lock_irq(&callback_lock); cs->flags = trialcs->flags; spin_unlock_irq(&callback_lock); -- 2.18.1