Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp4182470ybn; Fri, 27 Sep 2019 18:13:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxoVZ7LLfjGbSgGd9bsTVgw8icrHqe0OsDzc21ViKg8WNu1p/00yKftyWke+hAZ4dC9QQkG X-Received: by 2002:a05:6402:1681:: with SMTP id a1mr7732973edv.218.1569633229794; Fri, 27 Sep 2019 18:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569633229; cv=none; d=google.com; s=arc-20160816; b=l1aV/ixEQfCUkdCWwokZsnrQ+pxsC9PbMLPCVnB26R4gFqlfcLkQqBh5kpQzfbNOSm Q29hrLJv0a1wzEtuUDRJuDP8QnAUT1TDIDVKmZp/TgyJ9QCVDpjEI332P+6hOWxdzN/D B/1r+J9DNKygBBYfMrdB+D6920PZc4W2mZVuOammjrshvOU5YlZFdNsN0wIyLC8BssMj 4l0afwsAVtKAFZ2PAQ/9zfX4/wy0J3qWsmu1yNMUd31+uKTzM5arBp4Hy2aaqq6Hs879 AC+P49inIMeAVvldIwPAA9zqaqJ3r08KX7JkbXmpCFRlLe7L2kuCZ0WV0VmHNfBV0saG l8Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=sW45lQMpDbgMz1nniRjCoejjugeFjQRMAv7yZK5LIko=; b=CLBtnDCxorlhGCnEZkQg1b7vcLGfHsygDh1Oo0GM6Rf65qzn4CJqo1p14pZ2HsNsMt bVLb8QMeNtz8/OZWb7NXmlypdJpVUi5rM5IxZRWj23mG6kJ+QYuYXn4374vGGakwS/ny LicUuOVLs2KxUYYMK9AX84SOfg5R8GLjh6c3MDxcdYpgXpxC/TS7l8unaMSLra8gO341 af8RPN/Uj4PE24/TBYSVNT6bberAjllw3Ts8/UEDGVleubX8asX235apllDH/+aGp8Ss VXJu7V8tB2TB7REHzD4rCOvUUjDtdCJRI7OqDlBEc4v5MPeDevGZZq8WTLIU8JbS+Wvb rhhA== 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 20si3684019ejv.342.2019.09.27.18.12.54; Fri, 27 Sep 2019 18:13:49 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728464AbfI1BMv (ORCPT + 99 others); Fri, 27 Sep 2019 21:12:51 -0400 Received: from gentwo.org ([3.19.106.255]:49786 "EHLO gentwo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfI1BMu (ORCPT ); Fri, 27 Sep 2019 21:12:50 -0400 Received: by gentwo.org (Postfix, from userid 1002) id 438FF3EEC9; Sat, 28 Sep 2019 01:12:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id 413B93E8CB; Sat, 28 Sep 2019 01:12:49 +0000 (UTC) Date: Sat, 28 Sep 2019 01:12:49 +0000 (UTC) From: Christopher Lameter X-X-Sender: cl@www.lameter.com To: Vlastimil Babka cc: Andrew Morton , David Sterba , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Pekka Enberg , David Rientjes , Ming Lei , Dave Chinner , Matthew Wilcox , "Darrick J . Wong" , Christoph Hellwig , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, James Bottomley , linux-btrfs@vger.kernel.org, Roman Gushchin , Johannes Weiner Subject: Re: [PATCH v2 2/2] mm, sl[aou]b: guarantee natural alignment for kmalloc(power-of-two) In-Reply-To: <6a28a096-0e65-c7ea-9ca9-f72d68948e10@suse.cz> Message-ID: References: <20190826111627.7505-1-vbabka@suse.cz> <20190826111627.7505-3-vbabka@suse.cz> <20190923171710.GN2751@twin.jikos.cz> <20190924165425.a79a2dafbaf37828a931df2b@linux-foundation.org> <6a28a096-0e65-c7ea-9ca9-f72d68948e10@suse.cz> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Sep 2019, Vlastimil Babka wrote: > > - It will only work for special cases like the kmalloc array > > without extras like metadata at the end of objects. > > I don't understand what you mean here? The kmalloc caches are special > because they don't have metadata at the end of objects? Others do? Yes. > > - These alignments are only needed in exceptional cases but with the patch > > we will provide the alignment by default even if the allocating subsystem > > does not need it. > > True. This is where we have to make the decision whether to make things > simpler for those that don't realize they need the alignment, and > whether that's worth the cost. We have evidence of those cases, and the > cost is currently zero in the common cases (SLAB, SLUB without debug > runtime-enabled). The cost is zero for a particular layout of the objects in a page using a particular allocator and hardware configuration. However, the layout may be different due to another allocator that prefers to arrange things differently (SLOB puts multiple objects of different types in the same page to save memory), if we need to add data to these objects (debugging info, new metadata about the object, maybe the memcg pointer, maybe other things that may come up), or other innovative approaches (such as putting data of different kmem caches that are commonly used together in the same page to improve locality). The cost is an unnecessary petrification of the data layout of the memory allocators. > > - We have mechanisms to detect alignment problems using debug kernels and > > debug options that have been available for years. These were not used for > > testing in these cases it seems before the patches hit mainline. Once in > > mainly someone ran a debug kernel and found the issue. > > Debugging options are useful if you know there's a bug and you want to > find it. AFAIK the various bots/CIs that do e.g. randconfig, or enable > debug options explicitly, run those kernels in a VM, so I guess that's > why potential breakage due to alignment can lurk in a hw-specific driver. That is not my experience. You need to run debugging to verify that a patch does not cause locking problems, memory corruption etc etc. And upstream code is tested by various people with debugging kernels so they will locate the bugs that others introduce. This is usually not because there was a focus on a particular bug. If you have a hw specific thing that is not generally tested and skip the debugging tests well yes then we have a problem. What I have seen with developers is that they feel the debugging steps are unnecessary for conveniences sake. I have seen build environments that had proper steps for verification with a debug kernel. However, someone disabled them "some months ago" and "nothing happened". Then strange failures in production systems occur.