From patchwork Thu Sep 12 00:29:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 11141973 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 961CA16B1 for ; Thu, 12 Sep 2019 00:29:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6272E20CC7 for ; Thu, 12 Sep 2019 00:29:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="emTzcJuX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6272E20CC7 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 25E566B0272; Wed, 11 Sep 2019 20:29:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 20EE06B0273; Wed, 11 Sep 2019 20:29:36 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1255F6B028B; Wed, 11 Sep 2019 20:29:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0220.hostedemail.com [216.40.44.220]) by kanga.kvack.org (Postfix) with ESMTP id E10606B0272 for ; Wed, 11 Sep 2019 20:29:35 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 5F26E1F23D for ; Thu, 12 Sep 2019 00:29:35 +0000 (UTC) X-FDA: 75924385110.06.trade30_1978b0747c30b X-Spam-Summary: 2,0,0,fc24ab41e5a7c332,d41d8cd98f00b204,3bzf5xqykcggeafngumuumrk.iusrotad-ssqbgiq.uxm@flex--yuzhao.bounces.google.com,:cl@linux.com:penberg@kernel.org:rientjes@google.com:iamjoonsoo.kim@lge.com:akpm@linux-foundation.org:kirill@shutemov.name:penguin-kernel@i-love.sakura.ne.jp::linux-kernel@vger.kernel.org:yuzhao@google.com,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3152:3352:3865:3866:3867:3868:3870:3871:3872:4321:5007:6238:6261:6653:9969:10004:10400:11026:11473:11658:11914:12043:12048:12296:12297:12438:12533:12555:12679:12895:12986:13069:13311:13357:14096:14097:14181:14394:14659:14721:21080:21444:21451:21627:30054,0,RBL:209.85.214.201:@flex--yuzhao.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Cu stom_rul X-HE-Tag: trade30_1978b0747c30b X-Filterd-Recvd-Size: 4072 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Thu, 12 Sep 2019 00:29:34 +0000 (UTC) Received: by mail-pl1-f201.google.com with SMTP id c14so13009396plo.12 for ; Wed, 11 Sep 2019 17:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=M01d621+jXOeVOtLJvHlUCtiCRQEegusNaDlr2i35Sc=; b=emTzcJuXyc5nXp177ZHSHM8HRgJfjg3AKpTSMVLcZPdalmHovft+I1D/7rzfw7VwOh TlZYaA9+3FzgumZ+RmUsufI0V/n9gzRG3pZXqutN06yAcgJt/SV7SPgcD1uHe1bapO8t pcRbfp5fwduu7biTVNP4wRAtinetu06gIfYvCWzh2pfRxUg7mw2sWs5fnqof+qga3iIm Or/iDBDSWjDF+sv/XzgUN4QNq3Pw2/2ZKSs8PySJ2YSsGIJb+LAN/tFQRABq8+lH/lGv x4yNOaqzuMJa5G2QTcYWyZrq5ba+nKdHTZubsrpCMU3gPreVF2x1MyXKdSdRssDqBoRT rkVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=M01d621+jXOeVOtLJvHlUCtiCRQEegusNaDlr2i35Sc=; b=Id2hL92sxxjQ8rJ1WEd3/97wrpmDmT5ZccaFldyuSwXVEzvBlhPVehA23ll6lxFVI6 rJLXMHL6C6ABjfxW+FkeZU7AZ4vRkOtvzOS9f9EO1bpbULnq4QBKDEyFGbkV2CYHnV+G xLRhM97adcW7KeDqKl/4UQakwaCVLmQ1A4IAsn81ecFkpyJrsWbkPlDbL8gQFwvzzy5a XR2MLp+OUy1d8CrPfgABYe4P91FAuu1mRri9finhJtSbVbEoZgPCrE0hlafSpSlgLi1+ sFTKbM7gcVjhlkpKfHIeMuM9ztehfMjqGkMFz5wiLxXyduMXX3EfFyiJwYqpvkVt7OnE kaug== X-Gm-Message-State: APjAAAUKI3gX+zbtnpm44Ui1RiOa0QeTgCRWqZ2VIoDiieyynF1yhkRZ 68hPCgTMNRQ2sXG4sMnC/0qE0VQbhCE= X-Google-Smtp-Source: APXvYqxShYmRyX+l6llhto+SBqnYvELJgOERr5ICSUVl9FZCgvwep6WW53CesQ7KOZtdnfKF0jdq059FEGo= X-Received: by 2002:a63:3009:: with SMTP id w9mr36922043pgw.260.1568248173618; Wed, 11 Sep 2019 17:29:33 -0700 (PDT) Date: Wed, 11 Sep 2019 18:29:27 -0600 In-Reply-To: <20190911071331.770ecddff6a085330bf2b5f2@linux-foundation.org> Message-Id: <20190912002929.78873-1-yuzhao@google.com> Mime-Version: 1.0 References: <20190911071331.770ecddff6a085330bf2b5f2@linux-foundation.org> X-Mailer: git-send-email 2.23.0.162.g0b9fbb3734-goog Subject: [PATCH 1/3] mm: correct mask size for slub page->objects From: Yu Zhao To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , "Kirill A . Shutemov" , Tetsuo Handa Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Mask of slub objects per page shouldn't be larger than what page->objects can hold. It requires more than 2^15 objects to hit the problem, and I don't think anybody would. It'd be nice to have the mask fixed, but not really worth cc'ing the stable. Fixes: 50d5c41cd151 ("slub: Do not use frozen page flag but a bit in the page counters") Signed-off-by: Yu Zhao --- mm/slub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index 8834563cdb4b..62053ceb4464 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -187,7 +187,7 @@ static inline bool kmem_cache_has_cpu_partial(struct kmem_cache *s) */ #define DEBUG_METADATA_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER) -#define OO_SHIFT 16 +#define OO_SHIFT 15 #define OO_MASK ((1 << OO_SHIFT) - 1) #define MAX_OBJS_PER_PAGE 32767 /* since page.objects is u15 */ @@ -343,6 +343,8 @@ static inline unsigned int oo_order(struct kmem_cache_order_objects x) static inline unsigned int oo_objects(struct kmem_cache_order_objects x) { + BUILD_BUG_ON(OO_MASK > MAX_OBJS_PER_PAGE); + return x.x & OO_MASK; }