Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp812330img; Wed, 20 Mar 2019 11:23:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxG1gbVRsBEQKkaeUU08K1e5S0WijF9GUGIZjRPLdhxyYXn6euDq2EOkTmncl0CNrvQpbn+ X-Received: by 2002:a63:83:: with SMTP id 125mr8764853pga.403.1553106181818; Wed, 20 Mar 2019 11:23:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553106181; cv=none; d=google.com; s=arc-20160816; b=udWRqWRB/B17mGLkQ3aIXrtKPjzwLzSoMPOugyWhQ/2V+J84k1ZYUVopcOodVqlQXx J4FtZLi1Q65/hfswsxgxGBp0QWiDfUocktTYxlMANiPowz23YtIHteHKOVDL+ekxFcJ8 09V90bwTmeUH+8w3UtPpocQpVGWMnrlufw9ZSW9oRsxx1Y9RGi37VvcLl+/LxEJCs55e u+WzqNWhICrLBpBp/wjxC2awbgRoEZSwbYcjdyCSq7rri9Mr6QOFTlCQ5lpvKxpamIH8 5L2WXsG7G8tJpK0oMAFHMLuJ2edEEa6eJ6ES+1XZd8G/yLhwKJRMzeGfGVpyrmlAeHWk t3Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:mime-version:user-agent :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature; bh=K1oZPjp4GkcjqhAlXwpdoC8QkuglFFzbfMFyEVG/ri8=; b=NkQy8mXu2wbqAmqm7Bjvl6XKqAfO0utZFVuD7tfVoOAgB7sOClu25rs8B+EPU1Aq2J UmeyYAwHWuJP+njAkvbRP1rXB4MUEN4yL0BQlq+mu06jFcxpOw3jBWmDp/NIsTmKjEUt YZMEDjcetvR2T02IBhtWld0n20s3V1j7cOQq9DGBNnAnhd92BAulBJ3fOV40YP1LQVYi +o7yjtYNajySNEZMNGaytYYm72h8b09RFEct5FXLmD30lqkleMjVyAqPqkAzXBQncX6c 6eh3lPm8F+0E9IaGPE64bAOJEgCaA2LT+Nox2M9Ve/bk2Hhd9zVNHkesRgp+3r2caRvb 2Y9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazonses.com header.s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw header.b=ZRFeFu8F; 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 h24si2141187pgv.67.2019.03.20.11.22.46; Wed, 20 Mar 2019 11:23:01 -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; dkim=pass header.i=@amazonses.com header.s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw header.b=ZRFeFu8F; 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 S1727468AbfCTSUh (ORCPT + 99 others); Wed, 20 Mar 2019 14:20:37 -0400 Received: from a9-114.smtp-out.amazonses.com ([54.240.9.114]:42366 "EHLO a9-114.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726529AbfCTSUh (ORCPT ); Wed, 20 Mar 2019 14:20:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw; d=amazonses.com; t=1553106035; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type:Feedback-ID; bh=K1oZPjp4GkcjqhAlXwpdoC8QkuglFFzbfMFyEVG/ri8=; b=ZRFeFu8FwB5PFoGiDISVj+TujSsdT5LxaFcBw24dBiAw3s8dX/ozHAP1goU14WUg 89KwN2HZZEh3k+MaWDIK1WvM+y2GhhhEygM0P19pgj3L/y0/W4HuxQZDM2NFI52YXiI kp0kPy8HrfMfhkCmTppF60aC/AJ380WhvTMj0UOo= Date: Wed, 20 Mar 2019 18:20:35 +0000 From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Vlastimil Babka cc: linux-mm@kvack.org, Pekka Enberg , David Rientjes , Joonsoo Kim , Ming Lei , Dave Chinner , Matthew Wilcox , "Darrick J . Wong" , Christoph Hellwig , Michal Hocko , linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org Subject: Re: [RFC 0/2] guarantee natural alignment for kmalloc() In-Reply-To: <5d7fee9c-1a80-6ac9-ac1d-b1ce05ed27a8@suse.cz> Message-ID: <010001699c5563f8-36c6909f-ed43-4839-82da-b5f9f21594b8-000000@email.amazonses.com> References: <20190319211108.15495-1-vbabka@suse.cz> <01000169988d4e34-b4178f68-c390-472b-b62f-a57a4f459a76-000000@email.amazonses.com> <5d7fee9c-1a80-6ac9-ac1d-b1ce05ed27a8@suse.cz> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SES-Outgoing: 2019.03.20-54.240.9.114 Feedback-ID: 1.us-east-1.fQZZZ0Xtj2+TD7V5apTT/NrT6QKuPgzCT/IC7XYgDKI=:AmazonSES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 20 Mar 2019, Vlastimil Babka wrote: > > This means that the alignments are no longer uniform for all kmalloc > > caches and we get back to code making all sorts of assumptions about > > kmalloc alignments. > > Natural alignment to size is rather well defined, no? Would anyone ever > assume a larger one, for what reason? > It's now where some make assumptions (even unknowingly) for natural > There are two 'odd' sizes 96 and 192, which will keep cacheline size > alignment, would anyone really expect more than 64 bytes? I think one would expect one set of alighment for any kmalloc object. > > Currently all kmalloc objects are aligned to KMALLOC_MIN_ALIGN. That will > > no longer be the case and alignments will become inconsistent. > > KMALLOC_MIN_ALIGN is still the minimum, but in practice it's larger > which is not a problem. "In practice" refers to the current way that slab allocators arrange objects within the page. They are free to do otherwise if new ideas come up for object arrangements etc. The slab allocators already may have to store data in addition to the user accessible part (f.e. for RCU or ctor). The "natural alighnment" of a power of 2 cache is no longer as you expect for these cases. Debugging is not the only case where we extend the object. > Also let me stress again that nothing really changes except for SLOB, > and SLUB with debug options. The natural alignment for power-of-two > sizes already happens as SLAB and SLUB both allocate objects starting on > the page boundary. So people make assumptions based on that, and then > break with SLOB, or SLUB with debug. This patch just prevents that > breakage by guaranteeing those natural assumptions at all times. As explained before there is nothing "natural" here. Doing so restricts future features and creates a mess within the allocator of exceptions for debuggin etc etc (see what happened to SLAB). "Natural" is just a simplistic thought of a user how he would arrange power of 2 objects. These assumption should not be made but specified explicitly. > > I think its valuable that alignment requirements need to be explicitly > > requested. > > That's still possible for named caches created by kmem_cache_create(). So lets leave it as it is now then.