Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754661AbbGIWSG (ORCPT ); Thu, 9 Jul 2015 18:18:06 -0400 Received: from mail-bn1bbn0107.outbound.protection.outlook.com ([157.56.111.107]:15279 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752100AbbGIWR4 (ORCPT ); Thu, 9 Jul 2015 18:17:56 -0400 Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none; Message-ID: <1436480222.2658.151.camel@freescale.com> Subject: Re: [RFC] genalloc:add an gen_pool_alloc_align func to genalloc From: Scott Wood To: Laura Abbott CC: Zhao Qiang , , , , , , , Date: Thu, 9 Jul 2015 17:17:02 -0500 In-Reply-To: <559EECCF.6060702@redhat.com> References: <1436428063-893-1-git-send-email-B45475@freescale.com> <559EECCF.6060702@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.0-fta1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-IP: [2601:448:8100:f9f:12bf:48ff:fe84:c9a0] X-ClientProxiedBy: DM2PR22CA0016.namprd22.prod.outlook.com (25.162.205.26) To BY1PR03MB1481.namprd03.prod.outlook.com (25.162.210.14) X-Microsoft-Exchange-Diagnostics: 1;BY1PR03MB1481;2:3xBpr8xLaQTb5jHrReVLF0M/tfGKHuxjZEw+/iHbesK/t3nCUkFw3O5+Y2bMMXGy;3:qJ9Rhp4L9p3nk4771tM31/d4yfWUxwWzmK79arZeGnGqvIDIBtjqgQd0Pd6bqroCLrkSBFsTXRrTMBtqqNfRia5gazZFnkROYlLcG7JhN5PUMhD6aiMvwAIbNfebtM0Pjq5R0ko7SLKGC36LKyl+2w==;25:JIxT3iRTpKnLk+Xqix/EYmZWllQVils6HPsAfgOQi7K6tclVcbCx3bZchzNLmwd0Re4HlMsqI8kXgZCAz0fmLg0cpg2a12ViMfXIme0gtcKiJCJw9Ns2RwoAe7Qy0Z2aRs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Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BY1PR03MB1481;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1481; X-Forefront-PRVS: 0632519F33 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(377424004)(377454003)(479174004)(51704005)(36756003)(23676002)(5820100001)(50466002)(103116003)(92566002)(46102003)(77096005)(50226001)(2950100001)(42186005)(19580405001)(189998001)(19580395003)(33646002)(110136002)(50986999)(62966003)(77156002)(76176999)(47776003)(87976001)(5001920100001)(86362001)(122386002)(40100003)(5001960100002)(107886002)(3826002)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR03MB1481;H:[IPv6:2601:448:8100:f9f:12bf:48ff:fe84:c9a0];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTFQUjAzTUIxNDgxOzIzOjhQN2lNWHlhYUhQSkdsUlZEdlh1MGhhaFRa?= =?utf-8?B?Tkxla2JRMkg1T0pFZVNmQWpubm1nU01BQXNsQVB4VkJObnN1bi9nMWhXTHJB?= =?utf-8?B?dUFTVjdwbzc5d1J3SXFkUEdwdFA1MDFwcDJPbjYyRmZLNHNCZDZUQ25mbjlT?= =?utf-8?B?dmV4bnk0RjhLNVFlc3RRc3p5K1ZHdHNKMGFGd3M3UmlIZkp1cVI0eU5qazRZ?= =?utf-8?B?cW1uTDE1ZkljdFF4VTEwYWFmU3pmbkM4YTVDYkpoVUZQc2NwTU01dkQzY0FJ?= =?utf-8?B?TXM0U25SV2ZUQS8rc3RBS0xydnpPdkZzMWFNR1VrMWgyNVg3SnlsN0ZubDMr?= =?utf-8?B?eDJwNnhBdEZJYmpnTWhDZ2NnOVFrNk01S0tYWlpvTzF0ME1zWE9haVdUYWo5?= =?utf-8?B?VllqcVZTbHM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?dGhETTU3ZDIydVE9PQ==?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR03MB1481;5:L0IGsF2kXzN2aX0OajVRY+32WxJxLu6d8KMB1/Xs0GyxJsfa+7FNImbHUajVVU3Gj0Zuna6fNHzlnRIun9eTjWPsBE94W0RlVLKN2F/tLbA9X2Py0pGo97Ez4r+mfj+CmqqabR03kbajUsP6EIw0bg==;24:QFnq721CXu0+F4LuNqmSZJw9sKGIHX78E8dqlwGYd2JIxKK3asbYYH8runPCswTLpoZEKQBmaXZS/7IYGsKxGkffgvtGHd3zR+rY+8Uc3SA=;20:Sck9RsVPDro2grbVdUGNP7v3dkknk47d7YtUhnD99trOwMQ49I9uy2rBCFMv6AAl+ebUvQ0t6WIUTKNoFqsbFw== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2015 22:17:52.7617 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1481 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2548 Lines: 52 On Thu, 2015-07-09 at 14:51 -0700, Laura Abbott wrote: > On 07/09/2015 12:47 AM, Zhao Qiang wrote: > > Bytes alignment is required to manage some special ram, > > so add gen_pool_alloc_align func to genalloc. > > rename gen_pool_alloc to gen_pool_alloc_align with a align parameter, > > then provide gen_pool_alloc to call gen_pool_alloc_align with > > align = 1 Byte. > > > > Signed-off-by: Zhao Qiang > > --- > > FSL's IP block QE require this function to manage muram. > > QE supported only PowerPC, and its code was put under arch/powerpc > > directory, > > using arch/powerpc/lib/rheap.c to manage muram. > > Now it support both arm(ls1021,ls1043,ls2085 and such on) and powerpc, > > the code need to move from arch/powerpc to public direcory, > > Scott wood hopes to use genalloc to manage the muram, after discussing > > with scott, we decide to add gen_pool_alloc_align to meet the requirement > > for bytes-alignment. > > gen_pool supports custom allocation algorithms. I thought this was discussed > previously and the conclusion was that if you wanted alignment you should > use custom allocation algorithms. I'm failing at finding any thread > discussing it though. I hope that by "custom algorithm" you don't mean something implemented outside lib/genalloc.c, as this does not seem like such a specialized requirement that everyone must reimplement it separately. > Perhaps another option would be to add another runtime argument to gen_pool > where you could pass the alignment to your custom allocation function. This > way alignment isn't inherently coded into any of the algorithms. That wouldn't let the alignment change for each allocation (and could already be done with pool->data). I suppose one could call get_pool_set_algo() with different data (or modify the memory that pool->data is already pointing to) before each allocation, but that's a bit clunky... If making alignment part of the mainstream flow is undesired for some reason, how about a gen_pool_alloc_data() that lets it be passed in per-allocation (with gen_pool_alloc() being a wrapper that passes in pool->data)? Yes, I know, we could do it in a wrapper (like cpm_muram_alloc() unnecessarily does), but why not make the interface better match the way it's used? -Scott -- 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/