Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1096944imd; Thu, 1 Nov 2018 10:09:28 -0700 (PDT) X-Google-Smtp-Source: AJdET5fHpb5Vi33EtCH3St10mXviQjjNcpWBDS5Iv+Qlg1497mclZSxd/Cv1I51Al+v4quB6IUxY X-Received: by 2002:a62:8e0a:: with SMTP id k10-v6mr8712041pfe.182.1541092167996; Thu, 01 Nov 2018 10:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541092167; cv=none; d=google.com; s=arc-20160816; b=M4GXmC9OhXW428SU0zVRQfouYydWt2r9WhSL2gzKfIlzpWY4/6COQgCs2F+7bikJ4I wlErLKMTdZLYTwXucn8CgVx43pVgpPmsc0XnBxlTvydjQC7Pd5glCSVG3cGJRsrhGXUq FIW/fXnGMUS6Qp3NnrVEr6/553stwLw9T6espRvg1PJ6KDJwUo1pFykESFC9o4p+dpq4 Wl6ZivXf/br0Sz8y5s21LQn1FY9BpS04E0U0D45I767AaBMenoVbWIuUqQEVSdYsBnGW 5e++xKNT6XY988ZNbS3OFaUF7/LbiYw+LGHKYFPBrlgzA/qDDo3BejOid/shsoQ7L4BR zbnw== 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=a33yUWCamTfq1Z6ceYiwnuG1ZH3CKbKeGP0P538DGFw=; b=phfgD6Mr2CWBKm3A3Byj+cz3xD3t6ZQWWflJ9MiOsYfiC/Q7JQncl7CU6aotbFvhlo tdJ1raQ1/63VKfaQiLnher5kSL6ZhtZZbMaV6HAcHdE2Px+cBJmRN8Kjr5RmRfl5yd/+ EpmygM1/9lkcVVcxaz2JKdzE0bDoYBfBM/ey5Zr/8FshaTwtGdbpxlTmmORXcIPSOZ+z dRb/QSBJ5ftYI8RGPDXIVyxTkEdTZjGFfP+2GhJa3jJtFJMVA5hsCtN//NcYFCke8XpM pXAaA3BTSpRxDrd3FNj3KioVbJQ7LiSA2A7OAH9V4g99B0B2eW6D/Wie83ZHyhEHMJr5 z3/A== 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 d126-v6si30655713pgc.189.2018.11.01.10.09.13; Thu, 01 Nov 2018 10:09:27 -0700 (PDT) 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 S1726242AbeKBCLJ (ORCPT + 99 others); Thu, 1 Nov 2018 22:11:09 -0400 Received: from mga01.intel.com ([192.55.52.88]:57818 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725982AbeKBCLJ (ORCPT ); Thu, 1 Nov 2018 22:11:09 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2018 10:07:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,452,1534834800"; d="scan'208";a="82682643" Received: from kohsamui.iil.intel.com (HELO [10.236.193.12]) ([10.236.193.12]) by fmsmga007.fm.intel.com with ESMTP; 01 Nov 2018 10:07:18 -0700 Subject: Re: lib/genalloc To: Stephen Bates , "danielmentz@google.com" , "mathieu.desnoyers@efficios.co" Cc: Linux Kernel Mailing List , Laura Abbott References: <4DECD467-AD45-419D-8F0F-1456863274FD@raithlin.com> From: Alexey Skidanov Message-ID: Date: Thu, 1 Nov 2018 19:08: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: <4DECD467-AD45-419D-8F0F-1456863274FD@raithlin.com> 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/1/18 18:48, Stephen Bates wrote: >> I use gen_pool_first_fit_align() as pool allocation algorithm allocating >> buffers with requested alignment. But if a chunk base address is not >> aligned to the requested alignment(from some reason), the returned >> address is not aligned too. > > Alexey > > Can you try using gen_pool_first_fit_order_align()? Will that give you the alignment you need? > > Stephen > > I think it will not help me. Let's assume that the chunk base address is 0x2F400000 and I want to allocate 16MB aligned buffer. I get back the 0x2F400000. I think it happens because of this string in the gen_pool_alloc_algo(): addr = chunk->start_addr + ((unsigned long)start_bit << order); and the gen_pool_first_fit_align() implementation that doesn't take into account the "incorrect" chunk base alignment. It might be easily fixed, by rounding the start address up (0x2F400000 -> 0x30000000) and start looking from this, aligned, address. Thanks, Alexey