Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp246666imu; Thu, 8 Nov 2018 00:57:30 -0800 (PST) X-Google-Smtp-Source: AJdET5fidP6Hg1aNSCDypzv+ET6ymx6D5rHlVKuUovKHDoJbc/dtZkxwnsYPlykf31T4SEJkx4Gb X-Received: by 2002:a65:5286:: with SMTP id y6mr3084245pgp.439.1541667450231; Thu, 08 Nov 2018 00:57:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541667450; cv=none; d=google.com; s=arc-20160816; b=ikSnwLThp05oweNRU6pO9EAxljISuZsVCKBcEFRCH+E/JgdJ4yThCgSsL67OdyCVk/ +fJwORbUhqGMGRgBohUyvNhXPsqjsXcuKhVQyTyqehKqIW3n3TPX/rcyP05xImXnbqz+ C++/sHOYQA6jDzm/QqMC/RnZSsOPUBjI4E3fwROPutDHYfjIkkDCnTbbS7GmTpsSXn4Q RfzxA7b3++5bUip2onlhn6UooDarmIyOPb/Ta1c+OA0aOYwBCNlw9STfzzc+t3+cMTNI 2a1wDaEKvnZQW5YweZ5Rqyw5+AMo1GRHzBpJDRVlBmw+giE7qW+nHC6gVA3fsD099tKF ICfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=nAdgFsqSSSmmOtn45p4rau6dbp5EBryYmIlKfB8reUg=; b=tA5uCOCN84jPKZjdvfhrCDmRgmb+h/tlg2WkaAzPdIZs4k5XeUKoPKntPeBnbtVmu8 HgxPoBrlTG+0hpzyLPsZ2FrBB04i0q8RvUZiAOHuZHNmbW99ICIZJrYFWzCrv+rgyH5W p6HMfMuXe8cC34F22CfpAReL660cSTgeEbhdWjmG2PpRcE0xuDUKt8yYrePSxNsGBw60 6BRKWy7Idxm8U3e4EzeCRyBpC0Z8CxppKmj+XCsYBRNuXdihn5LbgYFelx+T9CXqkXbu Kxm4EBlH7J5mP1dilGG59+D3JWyGqzLmLqwfS0STSinIkr6MKyD+ITOhhcyByocfRdz0 xLKg== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s35si3038569pgk.392.2018.11.08.00.57.13; Thu, 08 Nov 2018 00:57:30 -0800 (PST) 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726667AbeKHS3p (ORCPT + 99 others); Thu, 8 Nov 2018 13:29:45 -0500 Received: from mga01.intel.com ([192.55.52.88]:18554 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726143AbeKHS3p (ORCPT ); Thu, 8 Nov 2018 13:29:45 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Nov 2018 00:55:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,478,1534834800"; d="scan'208";a="272358525" Received: from kohsamui.iil.intel.com (HELO [10.236.193.12]) ([10.236.193.12]) by orsmga005.jf.intel.com with ESMTP; 08 Nov 2018 00:55:14 -0800 Subject: Re: [PATCH] lib/genaloc: Fix allocation of aligned buffer from non-aligned chunk To: Andrew Morton Cc: sbates@raithlin.com, logang@deltatee.com, danielmentz@google.com, mathieu.desnoyers@efficios.com, linux-kernel@vger.kernel.org, labbott@redhat.com References: <1541506853-10685-1-git-send-email-alexey.skidanov@intel.com> <20181106141542.08a9d7de30a439ec9fe50486@linux-foundation.org> <20181107141244.624161486d7b187eb02b714a@linux-foundation.org> From: Alexey Skidanov Message-ID: <8d68007d-9be4-cf1b-2c6e-ed711fd3e673@intel.com> Date: Thu, 8 Nov 2018 10:56:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181107141244.624161486d7b187eb02b714a@linux-foundation.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/8/18 00:12, Andrew Morton wrote: > On Wed, 7 Nov 2018 08:27:31 +0200 Alexey Skidanov wrote: > >> >> >> On 11/7/18 12:15 AM, Andrew Morton wrote: >>> On Tue, 6 Nov 2018 14:20:53 +0200 Alexey Skidanov wrote: >>> >>>> On success, gen_pool_first_fit_align() returns the bit number such that >>>> chunk_start_addr + (bit << order) is properly aligned. On failure, >>>> the bitmap size parameter is returned. >>>> >>>> When the chunk_start_addr isn't aligned properly, the >>>> chunk_start_addr + (bit << order) isn't aligned too. >>>> >>>> To fix this, gen_pool_first_fit_align() takes into account >>>> the chunk_start_addr alignment and returns the bit value such that >>>> chunk_start_addr + (bit << order) is properly aligned >>>> (exactly as it done in CMA). >>>> >>>> ... >>>> >>>> --- a/include/linux/genalloc.h >>>> +++ b/include/linux/genalloc.h >>>> >>>> ... >>>> >>>> + struct gen_pool *pool, unsigned long start_add) >>>> >>>> ... >>>> >>>> + struct gen_pool *pool, unsigned long start_add) >>>> >>>> ... >>>> >>>> + struct gen_pool *pool, unsigned long start_add) >>>> >>>> ... >>>> >>> >>> We have three typos here. Which makes me wonder why we're passing the >>> new argument and then not using it? >>> >> genpool uses allocation callbacks function that implement some >> allocation strategy - bes fit, first fit, ... All of them has the same >> type. The added chunk start_addr is used only in one of them - >> gen_pool_first_fit_align() > > OK, but the argument name here is start_add, not start_addr. > Sure, I'll fix.