Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp130726imu; Wed, 7 Nov 2018 14:13:40 -0800 (PST) X-Google-Smtp-Source: AJdET5cY/Nmz2lvciFWWGakJc/9wveEQBkan3pS07GRpMBY5CIOsEAU6Qt3ru4m1pJhoyMOJE4hr X-Received: by 2002:a63:ec12:: with SMTP id j18mr1736168pgh.200.1541628820081; Wed, 07 Nov 2018 14:13:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541628820; cv=none; d=google.com; s=arc-20160816; b=MJkrA3/cHqPgvBImgZykXbw02hhcnkzPbb2XzZ1mjl0qPbRMjgdlY9d/5W2NTn8LQx SyBCQJWUeFCAFD1X/I3Qo3+OLkojyxMKMCWb+3e4PNGwGGBbtBJufZH9MArD6UZgXK0o 2L+wDOlcy9dnLXO8HPcql4E+G2IWDWy7nGukN5rvrhgytr+O8s6GFS983aa8HvnNi9N4 yPNB6N8C6yvhmMsfJS1fboAEsw3UMrfueOSjVdw+6qqasvr+g79SFQgAqGmWWZdj1a28 6TGSF/VN7a/sGF5Pw/3b5Rpr3fAKIfbfYZ5IjUnZCY7dhqg8rHRqOUbIEUr/AuF14yFQ EGyA== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=jxaL3Qc12kOorw1MglE3wThL9ZDfYuwRjYd8gTj8/Wk=; b=XFekYJu4YSo0A/UT/DiC6qwiVexAtTfdowMkm2NTz9Rr8L4ZrPj55nf40fQEW/v4sr A+56Cg3HYX/+li1VnmSHI+lxhR7mROHrn3qEK7m9HIA9+oB7qZ/oRJkXt7D9gXQ7R1qH JwuKG3PUMJLG3ew5hGqpygPJ8B1sfTW7xqewnZ/XBwOleW2qfAKKCiJrchs4kX5PQcnj l6ijVUhQs4qHAq7Nrh+crWXjwh4h97BkvSgfBbLd0EJMuOAP0PphjxVZKcrsNNFlg+VM gy3nClHYls4pkSG7G+oL/ApVuyelG0Hf3RpUTL7vhK9T8Lxl4q7RG2h2/tCY2uNzNhFP CBDg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a34si1657637pgm.427.2018.11.07.14.13.24; Wed, 07 Nov 2018 14:13:40 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727972AbeKHHpJ (ORCPT + 99 others); Thu, 8 Nov 2018 02:45:09 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:45988 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727454AbeKHHpJ (ORCPT ); Thu, 8 Nov 2018 02:45:09 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 268B0B37; Wed, 7 Nov 2018 22:12:46 +0000 (UTC) Date: Wed, 7 Nov 2018 14:12:44 -0800 From: Andrew Morton To: Alexey Skidanov Cc: sbates@raithlin.com, logang@deltatee.com, danielmentz@google.com, mathieu.desnoyers@efficios.com, linux-kernel@vger.kernel.org, labbott@redhat.com Subject: Re: [PATCH] lib/genaloc: Fix allocation of aligned buffer from non-aligned chunk Message-Id: <20181107141244.624161486d7b187eb02b714a@linux-foundation.org> In-Reply-To: References: <1541506853-10685-1-git-send-email-alexey.skidanov@intel.com> <20181106141542.08a9d7de30a439ec9fe50486@linux-foundation.org> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.