From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758744AbcIHU1y (ORCPT ); Thu, 8 Sep 2016 16:27:54 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:45888 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753787AbcIHU1w (ORCPT ); Thu, 8 Sep 2016 16:27:52 -0400 Date: Thu, 8 Sep 2016 22:25:06 +0200 (CEST) From: Thomas Gleixner To: Fenghua Yu cc: "H. Peter Anvin" , Ingo Molnar , Tony Luck , Peter Zijlstra , Tejun Heo , Borislav Petkov , Stephane Eranian , Marcelo Tosatti , David Carrillo-Cisneros , Shaohua Li , Ravi V Shankar , Vikas Shivappa , Sai Prakhya , linux-kernel , x86 Subject: Re: [PATCH v2 28/33] x86/intel_rdt_rdtgroup.c: Read and write cpus In-Reply-To: <1473328647-33116-29-git-send-email-fenghua.yu@intel.com> Message-ID: References: <1473328647-33116-1-git-send-email-fenghua.yu@intel.com> <1473328647-33116-29-git-send-email-fenghua.yu@intel.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 8 Sep 2016, Fenghua Yu wrote: > Normally each task is associated with one rdtgroup and we use the schema > for that rdtgroup whenever the task is running. The user can designate > some cpus to always use the same schema, regardless of which task is > running. To do that the user write a cpumask bit string to the "cpus" > file. Is that just a left over of the previous series or am I completely confused by now? > +static int cpus_validate(struct cpumask *cpumask, struct rdtgroup *rdtgrp) > +{ > + int old_cpumask_bit, new_cpumask_bit; > + int cpu; > + > + for_each_online_cpu(cpu) { > + old_cpumask_bit = cpumask_test_cpu(cpu, &rdtgrp->cpu_mask); > + new_cpumask_bit = cpumask_test_cpu(cpu, cpumask); > + /* Cannot clear a "cpus" bit in a rdtgroup. */ > + if (old_cpumask_bit == 1 && new_cpumask_bit == 0) > + return -EINVAL; > + } > + > + /* If a cpu is not online, cannot set it. */ > + for_each_cpu(cpu, cpumask) { > + if (!cpu_online(cpu)) > + return -EINVAL; > + } cpumask_intersects() exists for a reason. And how is this protected against cpu hotplug? > + list_for_each(l, &rdtgroup_lists) { > + r = list_entry(l, struct rdtgroup, rdtgroup_list); > + if (r == rdtgrp) > + continue; > + > + for_each_cpu_and(cpu, &r->cpu_mask, cpumask) > + cpumask_clear_cpu(cpu, &r->cpu_mask); This code clearly predates the invention of cpumask_andnot() Thanks, tglx