Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755312AbbHYIKe (ORCPT ); Tue, 25 Aug 2015 04:10:34 -0400 Received: from mail-bn1bon0142.outbound.protection.outlook.com ([157.56.111.142]:65056 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753279AbbHYIKH convert rfc822-to-8bit (ORCPT ); Tue, 25 Aug 2015 04:10:07 -0400 From: Zhao Qiang To: Laura Abbott , Scott Wood CC: "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "lauraa@codeaurora.org" , Xiaobo Xie , "benh@kernel.crashing.org" , Li Leo , "paulus@samba.org" Subject: RE: [PATCH v6 1/3] genalloc:support memory-allocation with bytes-alignment to genalloc Thread-Topic: [PATCH v6 1/3] genalloc:support memory-allocation with bytes-alignment to genalloc Thread-Index: AQHQ3lB3c5XRxGvlik2abkrI76vQZZ4bx5eAgAA6DyCAABcmAIAAQ7LA Date: Tue, 25 Aug 2015 08:09:56 +0000 Message-ID: References: <1440408703-6113-1-git-send-email-qiang.zhao@freescale.com> <55DBA477.5020608@redhat.com> <55DBE896.9030702@redhat.com> In-Reply-To: <55DBE896.9030702@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=qiang.zhao@freescale.com; x-originating-ip: [192.158.241.86] x-microsoft-exchange-diagnostics: 1;DM2PR0301MB0784;5:+MlyLvo+NcR/eMtbwkW9QKiwDbomOrcz6+rHuAn8+au/ZPogjNOq9RGGVAS2R9vhxnO7dK357KXyoMAD9jNabGnGp8fG3XWOS/rNRYnN7oRgwOUJL7kyWIDE70MTZpsLd3G71ay1PqjePSjH7lOiVw==;24:VS6/yCKFEUhmA1MXy+Q/usHBLRBTknJz0N2cKPMCQR7avdcFRl7Bni8xAd203kV0eh4Zok7la7Ne+DdPYHmbrFp0sADk8b3K+FmK4jIwg0g=;20:BIAhfNEX7fXIMJNcPkBal7WRI7wx112JK/J0s061eiqpx7Jou3WttcYFwnF59NNyAS6HO06/J/jfzxga3gQ0Ew== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0784; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(8121501046)(5005006)(3002001);SRVR:DM2PR0301MB0784;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0784; x-forefront-prvs: 06793E740F x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(377454003)(199003)(189002)(13464003)(24454002)(479174004)(164054003)(93886004)(81156007)(5001770100001)(4001450100002)(122556002)(97736004)(19580395003)(15975445007)(64706001)(5001830100001)(74316001)(5001860100001)(76576001)(19580405001)(10400500002)(5001960100002)(189998001)(4001540100001)(62966003)(40100003)(87936001)(77096005)(2950100001)(68736005)(2656002)(92566002)(46102003)(102836002)(105586002)(106356001)(77156002)(99286002)(50986999)(54356999)(101416001)(106116001)(86362001)(5004730100002)(5003600100002)(76176999)(5002640100001)(2900100001)(66066001)(5007970100001)(33656002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR0301MB0784;H:SN1PR0301MB1550.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Aug 2015 08:09:56.5623 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB0784 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4530 Lines: 120 On 08/25/2015 12:01 PM, Laura Abbott wrote: > -----Original Message----- > From: Laura Abbott [mailto:labbott@redhat.com] > Sent: Tuesday, August 25, 2015 12:01 PM > To: Zhao Qiang-B45475; Wood Scott-B07421 > Cc: linux-kernel@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; > lauraa@codeaurora.org; Xie Xiaobo-R63061; benh@kernel.crashing.org; Li > Yang-Leo-R58472; paulus@samba.org > Subject: Re: [PATCH v6 1/3] genalloc:support memory-allocation with > bytes-alignment to genalloc > > On 08/24/2015 07:40 PM, Zhao Qiang wrote: > > On 08/25/2015 07:11 AM, Laura Abbott wrote: > >> -----Original Message----- > >> From: Laura Abbott [mailto:labbott@redhat.com] > >> Sent: Tuesday, August 25, 2015 7:11 AM > >> To: Zhao Qiang-B45475; Wood Scott-B07421 > >> Cc: linux-kernel@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; > >> lauraa@codeaurora.org; Xie Xiaobo-R63061; benh@kernel.crashing.org; > >> Li Yang-Leo-R58472; paulus@samba.org > >> Subject: Re: [PATCH v6 1/3] genalloc:support memory-allocation with > >> bytes-alignment to genalloc > >> > >> On 08/24/2015 02:31 AM, Zhao Qiang wrote: > >>> Bytes alignment is required to manage some special RAM, so add > >>> gen_pool_first_fit_align to genalloc, meanwhile add > >>> gen_pool_alloc_data to pass data to gen_pool_first_fit_align(modify > >>> gen_pool_alloc as a wrapper) > >>> > >>> Signed-off-by: Zhao Qiang > >>> --- > >>> Changes for v6: > >>> - patches set v6 include a new patch because of using > >>> - genalloc to manage QE MURAM, patch 0001 is the new > >>> - patch, adding bytes alignment for allocation for use. > >>> > >>> include/linux/genalloc.h | 23 +++++++++++++++---- > >>> lib/genalloc.c | 58 > >> +++++++++++++++++++++++++++++++++++++++++++----- > >>> 2 files changed, 72 insertions(+), 9 deletions(-) > >>> > >>> diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h > >>> index 1ccaab4..55da07e 100644 > >>> --- a/include/linux/genalloc.h > >>> +++ b/include/linux/genalloc.h > >>> @@ -34,6 +34,7 @@ > >>> > >>> struct device; > >>> struct device_node; > >>> +struct gen_pool; > >>> > >>> /** > >>> * Allocation callback function type definition @@ -47,7 +48,7 @@ > >>> typedef unsigned long (*genpool_algo_t)(unsigned long *map, > >>> unsigned long size, > >>> unsigned long start, > >>> unsigned int nr, > >>> - void *data); > >>> + void *data, struct gen_pool *pool); > >>> > >>> /* > >>> * General purpose special memory pool descriptor. > >>> @@ -73,6 +74,13 @@ struct gen_pool_chunk { > >>> unsigned long bits[0]; /* bitmap for allocating memory > chunk > >> */ > >>> }; > >>> > >>> +/* > >>> + * gen_pool data descriptor for gen_pool_first_fit_align. > >>> + */ > >>> +struct genpool_data_align { > >>> + int align; /* alignment by bytes for starting address */ > >>> +}; > >>> + > >> > >> (sorry for chiming in late, I've been traveling) > >> > >> Is there an advantage here to wrapping this in a structure instead of > >> just passing a pointer to an align integer? > > > > > > Please look at the commit message for > > ca279cf1065fb689abea1dc7d8c11787729bb185 which adds "data": > > > > "As I can't predict all the possible requirements/needs for all > > allocation uses cases, I add a "free" field 'void *data' to pass any > > needed information to the allocation function. For example 'data' > > could be used to handle a structure where you store the alignment, the > > expected memory bank, the requester device, or any information that > > could influence the allocation algorithm." > > > > Right, I understand what the purpose is but I'm not sure what you're > getting from the structure vs passing a pointer, e.g. > > int align; > > align = 4; > > gen_pool_alloc_data(&pool, size, &align); > > it just seems to obfuscate what's going on by wrapping a single integer > in a structure that's narrowly defined in a generic function right now. I > guess it could change later which would necessitate having the structure > but again it's so generic I'm not sure what else you would pass that > would be applicable to all clients. Scott and me have discussed about this issue in my RFC patch. Please review: http://patchwork.ozlabs.org/patch/493297/ > > Thanks, > Laura -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/