Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4264412imm; Mon, 15 Oct 2018 11:44:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Y/bntSSYkAHZPgmsbzSjgY8mwu0OH04G+5bcDlJeMn81calUyocPWETouaRCayME2biyn X-Received: by 2002:a63:ef53:: with SMTP id c19-v6mr17119632pgk.386.1539629054778; Mon, 15 Oct 2018 11:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539629054; cv=none; d=google.com; s=arc-20160816; b=Fp7IPseOZpz3jkHHljWL2LW9HJHxjGeAiIGdfEw5hj0tspkFW7VWSJWyu5Sv34dAd1 SerIoi5aPoik81F1DySNEm63aCDInWj5UTeWFEUFBUEH3PrYMnXa305MBJhiBFMwqSpc L+1Uq+NK/Sr8+xR41pGPQ8cl+dRNy5rrtOsdh054vst+1Is27hHVnnWuvhAY7biozNA6 TWKdkxzJipnqH7pw/92deJKmK87ODa5eBCLBSYsKuhBzcuqeuvAERz4XgXrEwd8UHa1r xIGMPIkyglUyMNPyMCBd8kU40cvnU1/ntFMkeXkq6bXEBisgAmJ+851MT4FNgJFVWTp0 3Wcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=WZRwWdv2m2rMCZJkGkT5U47WfCtI/wVCyo5C0v2927w=; b=YDo237TO2Pg6x/fHC/pEDIKpNu0cBjxe4HwD7yAV/R3n6Br0zpEUWGLnFNV6L6arj0 /o+kJvPwkexOw2iRLyguwOvq04QJTs4eJNxWkZtiyAwSZ7fQWoKUoxxdYiiGtZ+3m2UG IPlRRyLO+1vbABeZKpWtMLR/8o4wclJrgRUna7u5ISHJWXBUy0JFBrVTrA3Vs0Kd8LAw mqf7VYIX58nu89eNoeSk5vglzSCugDywCiNiW1/j1i9HSBDhOQYBbtWMhDmMGmzH12vj vpJarvhnaKpgK0T9tUBSSlX4eKNZV6cyeksKgs8BU12+wN3pP0J9mr5NimcsAuDjoixs 8b6g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5-v6si11352468pga.576.2018.10.15.11.43.59; Mon, 15 Oct 2018 11:44:14 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726986AbeJPC35 (ORCPT + 99 others); Mon, 15 Oct 2018 22:29:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58086 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726594AbeJPC35 (ORCPT ); Mon, 15 Oct 2018 22:29:57 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 46C4D308626E; Mon, 15 Oct 2018 18:43:29 +0000 (UTC) Received: from llong.remote.csb (dhcp-17-8.bos.redhat.com [10.18.17.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9544262480; Mon, 15 Oct 2018 18:43:22 +0000 (UTC) Subject: Re: [PATCH v13 03/11] cpuset: Simply allocation and freeing of cpumasks To: Tom Hromatka , Tejun Heo , Li Zefan , Johannes Weiner , Peter Zijlstra , Ingo Molnar Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kernel-team@fb.com, pjt@google.com, luto@amacapital.net, Mike Galbraith , torvalds@linux-foundation.org, Roman Gushchin , Juri Lelli , Patrick Bellasi References: <1539366951-8498-1-git-send-email-longman@redhat.com> <1539366951-8498-4-git-send-email-longman@redhat.com> From: Waiman Long Organization: Red Hat Message-ID: Date: Mon, 15 Oct 2018 14:43:22 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 15 Oct 2018 18:43:29 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/15/2018 02:35 PM, Tom Hromatka wrote: > > > On 10/12/2018 11:55 AM, Waiman Long wrote: >> The previous commit introduces a new subparts_cpus mask into the cpuset >> data structure and a new tmpmasks structure. Managing the allocation >> and freeing of those cpumasks is becoming more complex. >> >> So a number of helper functions are added to simplify and streamline >> the management of those cpumasks. To make it simple, all the cpumasks >> are now pre-cleared on allocation. >> >> Signed-off-by: Waiman Long >> --- >> kernel/cgroup/cpuset.c | 104 >> +++++++++++++++++++++++++++++++++---------------- >> 1 file changed, 71 insertions(+), 33 deletions(-) >> >> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c >> index 29a2bdc..9ac5f94 100644 >> --- a/kernel/cgroup/cpuset.c >> +++ b/kernel/cgroup/cpuset.c >> @@ -456,6 +456,57 @@ static int is_cpuset_subset(const struct cpuset >> *p, const struct cpuset *q) >> } >> /** >> + * alloc_cpumasks - allocate three cpumasks for cpuset >> + * @cs: the cpuset that have cpumasks to be allocated. >> + * @tmp: the tmpmasks structure pointer >> + * Return: 0 if successful, -ENOMEM otherwise. >> + * >> + * Only one of the two input arguments should be non-NULL. >> + */ >> +static inline int alloc_cpumasks(struct cpuset *cs, struct tmpmasks >> *tmp) >> +{ >> + cpumask_var_t *pmask1, *pmask2, *pmask3; >> + >> + if (cs) { >> + pmask1 = &cs->cpus_allowed; >> + pmask2 = &cs->effective_cpus; >> + pmask3 = &cs->subparts_cpus; >> + } else { >> + pmask1 = &tmp->new_cpus; >> + pmask2 = &tmp->addmask; >> + pmask3 = &tmp->delmask; >> + } >> + >> + if (!zalloc_cpumask_var(pmask1, GFP_KERNEL)) >> + return -ENOMEM; >> + >> + if (!zalloc_cpumask_var(pmask2, GFP_KERNEL)) >> + goto free_one; >> + >> + if (!zalloc_cpumask_var(pmask3, GFP_KERNEL)) >> + goto free_two; >> + >> + return 0; >> + >> +free_two: >> + free_cpumask_var(*pmask2); >> +free_one: >> + free_cpumask_var(*pmask1); >> + return -ENOMEM; >> +} >> + >> +/** >> + * free_cpumasks - free cpumasks in a tmpmasks structure >> + * @tmp: the tmpmasks structure pointer >> + */ >> +static inline void free_cpumasks(struct tmpmasks *tmp) >> +{ >> + free_cpumask_var(tmp->new_cpus); >> + free_cpumask_var(tmp->addmask); >> + free_cpumask_var(tmp->delmask); >> +} >> + > > I hesitate to bring this up, but since you're respinning this > patch for a different bug... > > Would it make sense to have free_cpumasks() have a similar > API and behavior to alloc_cpumasks()? I could see this potentially > causing bugs/confusion in future patches. > > Thanks. > > Tom > > Thanks for the comment. Yes I will make the change. -Longman