From patchwork Tue Mar 19 21:11:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 10860351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ECC7814DE for ; Tue, 19 Mar 2019 21:11:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1F43298C7 for ; Tue, 19 Mar 2019 21:11:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5D93298CA; Tue, 19 Mar 2019 21:11:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B7A4298C7 for ; Tue, 19 Mar 2019 21:11:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727555AbfCSVL3 (ORCPT ); Tue, 19 Mar 2019 17:11:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:41338 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726627AbfCSVL3 (ORCPT ); Tue, 19 Mar 2019 17:11:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 96729B607; Tue, 19 Mar 2019 21:11:27 +0000 (UTC) From: Vlastimil Babka To: linux-mm@kvack.org Cc: Christoph Lameter , 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, Vlastimil Babka Subject: [RFC 0/2] guarantee natural alignment for kmalloc() Date: Tue, 19 Mar 2019 22:11:06 +0100 Message-Id: <20190319211108.15495-1-vbabka@suse.cz> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The recent thread [1] inspired me to look into guaranteeing alignment for kmalloc() for power-of-two sizes. Turns out it's not difficult and in most configuration nothing really changes as it happens implicitly. More details in the first patch. If we agree we want to do this, I will see where to update documentation and perhaps if there are any workarounds in the tree that can be converted to plain kmalloc() afterwards. The second patch is quick and dirty selftest for the alignment. Suggestions welcome whether and how to include this kind of selftest that has to be in-kernel. [1] https://lore.kernel.org/linux-fsdevel/20190225040904.5557-1-ming.lei@redhat.com/T/#u Vlastimil Babka (2): mm, sl[aou]b: guarantee natural alignment for kmalloc(power-of-two) mm, sl[aou]b: test whether kmalloc() alignment works as expected mm/slab_common.c | 30 +++++++++++++++++++++++++++++- mm/slob.c | 42 +++++++++++++++++++++++++++++++----------- 2 files changed, 60 insertions(+), 12 deletions(-)