Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2412036imu; Tue, 6 Nov 2018 14:12:19 -0800 (PST) X-Google-Smtp-Source: AJdET5e6N8Xq1GT+dt0OX33UOGjsbxPgM8UkDlta0Q5CWsiTwzgQzsbzTMAx8S5SONPZInl8FtKh X-Received: by 2002:a17:902:6e08:: with SMTP id u8-v6mr28036412plk.64.1541542339843; Tue, 06 Nov 2018 14:12:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541542339; cv=none; d=google.com; s=arc-20160816; b=YqdZMg6IF+M4MTUbBe+pdXkG8FmBEKyLytII6FPbKEVWOG/Bz9fwnvb3jFYfoauMOy +Xqjw7obLDlKiI0Ot6737t3GtvqV5mShgqarH8oUsK25ajI+5idf0+Ha0xE2QjHJ4YQL U+L96LxvVtQj5GOZCrykA9GISfaActNcWILhi3tS/Pg0AhknyhV7v+Un02iNNrx6h3aZ GK0UxskxBYdeXlW14Qep59VtVzEWSFwkXt2pRBKoX3NZmJnv18Nnluwh3btdeExzBTiA mzNBU77Ms/wpDAv+OYA4BWBWnsRoCAbwlrN9XkTn/NV3vmhrkdINq4284iAmYLT5TVO8 IKUw== 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=Ubs1g/yrGcGnEJb3NQ4vKYszBfMLFETTpQ35c/ddmoI=; b=wkny5V2RBHZvs5JNsK3veoKlQzH/yTRde4TX/Xosu3Cj4XU86gB3RejgUIYL5oezwn DiGKSX2Q3FGRV/JeCPnGqzCNU1xiXMaXVX4XDG6L9WCnu+cqit1UVGeN4bPpbZCTqpPO Fn5yZaVOyAWb6qe4TYLrFEtFotrY0dTLTg4litq3twimc4rkT15HeWnP+oB8jSckZRqu XXg+Z3xp61i15QUV8ZwB6u1fiVXldkkwYXGAKoL7tUkNMUj27OhA7sPtnDWuWZfyXict st1TIof4eIr6fI94huCH/BMlrI+/v2MlrKSKferkpeLIiMYUAKOu5bE3LVSyLcvjORlX 4MGA== 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 b59-v6si53265743plb.206.2018.11.06.14.12.05; Tue, 06 Nov 2018 14:12:19 -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 S1730901AbeKGHi5 (ORCPT + 99 others); Wed, 7 Nov 2018 02:38:57 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:57048 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726462AbeKGHi5 (ORCPT ); Wed, 7 Nov 2018 02:38:57 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3113F72A; Tue, 6 Nov 2018 22:11:33 +0000 (UTC) Date: Tue, 6 Nov 2018 14:11:31 -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: <20181106141131.76e94f6b1ff2859d96792aca@linux-foundation.org> In-Reply-To: <1541506853-10685-1-git-send-email-alexey.skidanov@intel.com> References: <1541506853-10685-1-git-send-email-alexey.skidanov@intel.com> 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 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). Why does this need "fixing"? Are there current callers which can misalign chunk_start_addr? Or is there a requirement that future callers can misalign chunk_start_addr?