Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp7955img; Tue, 19 Mar 2019 14:14:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqziJigmB7SuN1pYMkzjoLqt/0des4y98LXDpxOaFyrm0D42uONkxaDEho3t0d8JI6f4aBCQ X-Received: by 2002:a62:6ec3:: with SMTP id j186mr4093764pfc.89.1553030054212; Tue, 19 Mar 2019 14:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553030054; cv=none; d=google.com; s=arc-20160816; b=DwbqSDdxHDMj5RDCoGkweSjVDHqnncZXr5STyzc83VfEEEhnk03Lg6F2w8x2Utg1r7 emra2efHCSUFrsCtCG0UfGux53wVVGOuuJ04y+e5tnLxIPADPgfEbFooNADVADOmbcwI yeIzzozTpi9y9u8YRxVRShW2O8IhdwoQwdZJdTQee4uqviCAgU3/RHsNLoIyiTAibhW5 Z9rXnqiNBiVpObwPEeGkVHcyshm1+sawI9TX69L8UWJBu9wE/6HEpirU+cD1IS4eoUIa g1bXTJbTW1yZa3cNEAXDTsyIQK3mihKOhah/tvJUrZFC4Si99ua6dXptqOYu2Nely7hs /P0w== 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:date:subject:cc:to:from; bh=YhEnIqCavVt6SwF55Ols042rQ/lBzw+OT1XOU0MPciQ=; b=sjILYufdv+nUhqz0TXMTv9fSD/k3MdVWmmcy9NFH1HLqnuf8pyD2BztToDmlP5avds iqbYY0zz4UEkxLdlF8mengYp68SP4Oy7WF6vsElfzGqRSVvWVUEoraPbPglquetF9VV7 iiAZ2Kl66Yqe3QGJCPGlfRJq2ZZeTR573U9nAUEdGQ+RlSG8wTvhI795BLAkEwDqRxar /7mry34QWTMYqN1k8mZgr5Ht0Ewq/e75DgR7oOdfshjw3p1NK24Q2yZibdXa6z0BZY6b e9oRHdzlceEyu3+LhShp42TM7uwmavTfGYRyKc0FNQKBWIyCZytLyMxkM2UEvDRM3yO2 QDww== 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 r11si11806391pgp.433.2019.03.19.14.13.58; Tue, 19 Mar 2019 14:14:14 -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 S1727637AbfCSVLa (ORCPT + 99 others); Tue, 19 Mar 2019 17:11:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:41356 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726740AbfCSVL3 (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 9655EB606; 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 2/2] mm, sl[aou]b: test whether kmalloc() alignment works as expected Date: Tue, 19 Mar 2019 22:11:08 +0100 Message-Id: <20190319211108.15495-3-vbabka@suse.cz> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190319211108.15495-1-vbabka@suse.cz> References: <20190319211108.15495-1-vbabka@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quick and dirty init test that kmalloc() alignment works as expected for power-of-two sizes after the previous patch. Signed-off-by: Vlastimil Babka --- mm/slab_common.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mm/slab_common.c b/mm/slab_common.c index e591d5688558..de10ca9640e0 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -1621,3 +1621,22 @@ int should_failslab(struct kmem_cache *s, gfp_t gfpflags) return 0; } ALLOW_ERROR_INJECTION(should_failslab, ERRNO); + +static int __init slab_kmalloc_test(void) +{ + int i; + + for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) { + unsigned int size = 1 << i; + void * obj = kmalloc(size, GFP_KERNEL); + unsigned long objaddr = (unsigned long) obj; + + printk("Size %u obj %px alignment: %s", size, obj, + (((objaddr & (size - 1)) == 0) ? "OK" : "WRONG")); + kfree(obj); + } + + return 0; +} + +__initcall(slab_kmalloc_test); -- 2.21.0