From patchwork Thu Sep 4 10:43:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 36687 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 10FBA202E4 for ; Thu, 4 Sep 2014 10:44:04 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id 29sf34427469yhl.2 for ; Thu, 04 Sep 2014 03:44:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:references:in-reply-to:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe :content-type:content-transfer-encoding; bh=jLtD+LNd/Bxqa4FmqDeaqH+nwp3YLX9pcmHH/0KSsJg=; b=jVTRFX0ISccKSOHyE3aR5A4ttuqblVBdRukJmJcX3/fSdx8JaChOzzxlq5dYcqGXUA Zl9M35n7X4YL2o4MPTkOI71pC0RMJyGObP+mynHUJFkwioy8d+P1nUftfKn9Le2hD8h0 Ju0Z0AuumT4cChtMpfRzsexaneScoo6fDSKZs02AZQ+6lu/IUCxdVdHWfDPet3iTdFMX bBYCUSXUcFrcmvNRZKTEPygBnfLtTCSL9tEkmfQqxWNIf1IpZprewIA9GqycPXF1P6Bz Rgs+IyWNqNESwrTCIHyvdYM8X8vDgV3SJWvsdKJJlD5AWMXzt12RGqK8Qn8LYY/DBHKP +Zng== X-Gm-Message-State: ALoCoQnEK+QiVSLfVG3AcC0TVs6iWxZGWA/Euf6xsMS06sxPKId1nkSDCdhF34CQK+zaIUtEWBQQ X-Received: by 10.236.44.205 with SMTP id n53mr1937043yhb.12.1409827443839; Thu, 04 Sep 2014 03:44:03 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.228 with SMTP id b91ls218236qge.88.gmail; Thu, 04 Sep 2014 03:44:03 -0700 (PDT) X-Received: by 10.221.6.201 with SMTP id ol9mr2751336vcb.2.1409827443670; Thu, 04 Sep 2014 03:44:03 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id yk10si2658814vdb.43.2014.09.04.03.44.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Sep 2014 03:44:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id ij19so10373556vcb.17 for ; Thu, 04 Sep 2014 03:44:03 -0700 (PDT) X-Received: by 10.220.132.207 with SMTP id c15mr2779641vct.12.1409827443573; Thu, 04 Sep 2014 03:44:03 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp813282vcb; Thu, 4 Sep 2014 03:44:03 -0700 (PDT) X-Received: by 10.70.127.207 with SMTP id ni15mr7061035pdb.129.1409827442508; Thu, 04 Sep 2014 03:44:02 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vy2si3061901pab.18.2014.09.04.03.43.53 for ; Thu, 04 Sep 2014 03:43:54 -0700 (PDT) Received-SPF: none (google.com: linux-acpi-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752632AbaIDKnV (ORCPT + 7 others); Thu, 4 Sep 2014 06:43:21 -0400 Received: from service87.mimecast.com ([91.220.42.44]:60476 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751070AbaIDKnT convert rfc822-to-8bit (ORCPT ); Thu, 4 Sep 2014 06:43:19 -0400 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 04 Sep 2014 11:43:17 +0100 Received: from [10.1.207.142] ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 4 Sep 2014 11:43:15 +0100 Message-ID: <54084246.7010705@arm.com> Date: Thu, 04 Sep 2014 11:43:18 +0100 From: Sudeep Holla User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Peter Zijlstra CC: Sudeep Holla , LKML , Heiko Carstens , Lorenzo Pieralisi , Greg Kroah-Hartman , "Rafael J. Wysocki" , Bjorn Helgaas , "x86@kernel.org" , "linux-acpi@vger.kernel.org" , "linux-pci@vger.kernel.org" Subject: Re: [PATCH v4 01/11] cpumask: factor out show_cpumap into separate helper function References: <1409763617-17074-1-git-send-email-sudeep.holla@arm.com> <1409763617-17074-2-git-send-email-sudeep.holla@arm.com> <20140904062006.GC3190@worktop.ger.corp.intel.com> <54082ADD.6040004@arm.com> <20140904092135.GA346@worktop.programming.kicks-ass.net> In-Reply-To: <20140904092135.GA346@worktop.programming.kicks-ass.net> X-OriginalArrivalTime: 04 Sep 2014 10:43:15.0936 (UTC) FILETIME=[0889B600:01CFC82D] X-MC-Unique: 114090411431704701 Sender: linux-acpi-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sudeep.holla@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Hi Peter, On 04/09/14 10:21, Peter Zijlstra wrote: > On Thu, Sep 04, 2014 at 10:03:25AM +0100, Sudeep Holla wrote: >> If I don't, every file including this header generates "warning: >> ‘cpumap_copy_to_buf’ defined but not used". Alternatively I can just >> declare here and define it elsewhere but I could not find more apt >> place than this. Any suggestions ? kernel/cpu.c ? > > Sure the tail of cpu.c seems to have various other cpumask gunk in > already so it fits there. The other alternative would've been > lib/bitmap.c since that's where the various bitmap printf > implementations live. > > You could make it bitmap_copy_to_buf() I suppose, and then have a > cpumask inline wrapper, to be fully consistent with the rest of the > implementations. > I liked the second approach, how about patch below ? If will munge it into original patch. --->8 * __bitmap_parselist - convert list format ASCII string to bitmap * @buf: read nul-terminated user string from this buffer * @buflen: buffer size in bytes. If string is smaller than this --- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index e1c8d080c427..34586d386c1f 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -60,6 +60,7 @@ * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region * bitmap_release_region(bitmap, pos, order) Free specified bit region * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region + * bitmap_copy_to_pagebuf(list, src, buf) Print bitmap src as list/hex to buf */ /* @@ -145,6 +146,8 @@ extern void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int o extern int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order); extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits); extern int bitmap_ord_to_pos(const unsigned long *bitmap, int n, int bits); +extern int bitmap_copy_to_pagebuf(bool list, const unsigned long *maskp, + char *buf); #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG)) #define BITMAP_LAST_WORD_MASK(nbits) \ diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 26d8348292dd..5b3bd163c5a0 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -807,16 +807,7 @@ static inline const struct cpumask *get_cpu_mask(unsigned int cpu) static inline ssize_t cpumap_copy_to_buf(bool list, const struct cpumask *mask, char *buf) { - ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf - 2; - int n = 0; - - if (len > 1) { - n = list ? cpulist_scnprintf(buf, len, mask) : - cpumask_scnprintf(buf, len, mask); - buf[n++] = '\n'; - buf[n] = '\0'; - } - return n; + return bitmap_copy_to_pagebuf(list, cpumask_bits(mask), buf); } sudeep@e103737-lin:~/work/power/kernel$ git diff > /tmp/log sudeep@e103737-lin:~/work/power/kernel$ cat /tmp/log diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index e1c8d080c427..34586d386c1f 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -60,6 +60,7 @@ * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region * bitmap_release_region(bitmap, pos, order) Free specified bit region * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region + * bitmap_copy_to_pagebuf(list, src, buf) Print bitmap src as list/hex to buf */ /* @@ -145,6 +146,8 @@ extern void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int o extern int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order); extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits); extern int bitmap_ord_to_pos(const unsigned long *bitmap, int n, int bits); +extern int bitmap_copy_to_pagebuf(bool list, const unsigned long *maskp, + char *buf); #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG)) #define BITMAP_LAST_WORD_MASK(nbits) \ diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 26d8348292dd..5b3bd163c5a0 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -807,16 +807,7 @@ static inline const struct cpumask *get_cpu_mask(unsigned int cpu) static inline ssize_t cpumap_copy_to_buf(bool list, const struct cpumask *mask, char *buf) { - ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf - 2; - int n = 0; - - if (len > 1) { - n = list ? cpulist_scnprintf(buf, len, mask) : - cpumask_scnprintf(buf, len, mask); - buf[n++] = '\n'; - buf[n] = '\0'; - } - return n; + return bitmap_copy_to_pagebuf(list, cpumask_bits(mask), buf); } /* diff --git a/lib/bitmap.c b/lib/bitmap.c index 1e031f2c9aba..b23adef04d7e 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -580,6 +580,32 @@ int bitmap_scnlistprintf(char *buf, unsigned int buflen, EXPORT_SYMBOL(bitmap_scnlistprintf); /** + * bitmap_copy_to_pagebuf - convert bitmap to list or hex format ASCII string + * @list: indicates whether the bitmap must be list + * @maskp: pointer to bitmap to convert + * @buf: page aligned buffer into which string is placed + * + * Output format is a comma-separated list of decimal numbers and + * ranges if list is specified or hex digits grouped into comma-separated + * sets of 8 digits/set. Returns the number of characters written to buf. + */ +int bitmap_copy_to_pagebuf(bool list, const unsigned long *maskp, char *buf) +{ + ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf - 2; + int n = 0; + + if (len > 1) { + n = list ? + bitmap_scnlistprintf(buf, len, maskp, nr_cpumask_bits) : + bitmap_scnprintf(buf, len, maskp, nr_cpumask_bits); + buf[n++] = '\n'; + buf[n] = '\0'; + } + return n; +} +EXPORT_SYMBOL(bitmap_copy_to_pagebuf); + +/**