Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1656565ybe; Wed, 11 Sep 2019 19:33:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvXwKg4sJ74awnzBLrGMTeSmtpAl1NTt119Vv0tV/DXMExtkMUfOJZYGCyj7frSy5fE/bz X-Received: by 2002:a50:99da:: with SMTP id n26mr23500408edb.293.1568255632557; Wed, 11 Sep 2019 19:33:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568255632; cv=none; d=google.com; s=arc-20160816; b=QXnoWjT77fBFf+L3BanmfUcMnGvBpFoR7PvNgSauKt0gzLCrBDuRXdhQEGdca7zy1N oJvptgqJkeAFNKmEX37sBLVBXd1DYVCMltLKOtmBhFXEpHZxjQ+RO+WW6/6TIR9BEmyt DPAEbs5Snut0qaYo4fC3zrT2zjaVZt0ANtXdFJ8GheqQNnppw31dZYhhgXT0ZijM/1nr 6YW4yJi9uhZ5Rc7OylmQ4sTqcGVeFAtoTHfyltzPmkfy3G22OizzKrzz3UM/zNjYlfMA YzPOx5Y0xhoRNBk4LNmYmCLrgTL6AZfC4BIp1L4WI74TAe1gRXrrRlM/2X17RWJ5BCx4 43zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=M01d621+jXOeVOtLJvHlUCtiCRQEegusNaDlr2i35Sc=; b=doDh2viHXxY3CJM2cU41cCR9B+1dhWTdMC5uSF9h3AmvDC6IQvF/8xTC4Voea6Fcdg 08/dzvYjiwggXBQBH7LX/upnss9xWCPDca6GLEyU6C2HR+Ee7W6shkODiFCyeMKG2b5q ku/jRAF6lBxPBQq2Wqxbrnu9QV0zb3DP4K4L9VT9RX5q6YBnyAEcDCAyFoSsP8L25k7S EO4MNH6L6r/zCpgRwQkQ9QkX3cXwz0q0dKNApRxbhp4CyMhd9ZugFs1IB1x3ky0oJJkN nr1B6J0YDTF3d5LcMbfJOtQCeSnAvXfXDUnTLQvV/44yVQlY3gWqfHmiUAVPN0aFa7ra 9nYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=POAOLSgR; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si13927729edc.75.2019.09.11.19.33.14; Wed, 11 Sep 2019 19:33:52 -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=@google.com header.s=20161025 header.b=POAOLSgR; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728861AbfILCbP (ORCPT + 99 others); Wed, 11 Sep 2019 22:31:15 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:34306 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727477AbfILCbP (ORCPT ); Wed, 11 Sep 2019 22:31:15 -0400 Received: by mail-pf1-f201.google.com with SMTP id v6so5445712pfm.1 for ; Wed, 11 Sep 2019 19:31:14 -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=POAOLSgRgwPfDzOISo1MKH/2QLeqTomKY/wS1QotRgVb+fnKfk6pEqTsN/5no3Yb3S Q5gAVgxxV+ZQKy+l3JYU/B1KiQJSM9FrAz+2rSwbmQm+8ozbJxvc6yf9QD2AWui2kVQF IHnCKQWi3MGZhSBAFzveRDOPGWpx/LU/lf39HC0SpCVhsnAg+l9peNmmIjSehuOq1RVW M/MRonGRnTVovm/fmrHgANDs4dtA5VQw1clG8EniSSFxLN36ZtbuwWeoVt164qoMELUZ X/rjZ1tQSHJA/LTXAUcXSM2SQMofSmH/P5odvUxHBR6hhvJsflCDHFpxxx5hCHaSOMcp tEvw== 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=qw7otLg1auK9i3A/R8KCt8pK2/w8K9e4m6jcPWc/zP66/1GsVA1svMTDHwW729G2iu HvPPVhnAskmudd3PfLO52YvW2cmcyK7WuxQlqhXeWKMmb1l8AIuRJfmb6lcMg8ZJs+iq Q4/wRG49ZatPukFCqaekt4p8l5HCcprjBklszP1KJS7D1QTCTkb4wtGCYdUpJ1hLTFZW Pgct6F49o8i9Sy0yi2/N079I6EjmyAeKA4Ot1e4FLHFSyvnNbgQSLfDWmM4sYl4la0zv OkIdK4TWaoGOMeTGSMw/O7VV2Q+8KPqvpFRKLFIyHwWuas8Xn3/tzOwUc0r+nuJkxoTd XoDw== X-Gm-Message-State: APjAAAWuXuk+Ofx795K3NEAhe4UgdN+1gUHyQQz3YxVsy/8cSYWmd9RB 6i0D1u1ZgfS5ThKVmJ7ponIKskF+DdU= X-Received: by 2002:a65:6546:: with SMTP id a6mr36882579pgw.220.1568255474084; Wed, 11 Sep 2019 19:31:14 -0700 (PDT) Date: Wed, 11 Sep 2019 20:31:08 -0600 In-Reply-To: <20190912004401.jdemtajrspetk3fh@box> Message-Id: <20190912023111.219636-1-yuzhao@google.com> Mime-Version: 1.0 References: <20190912004401.jdemtajrspetk3fh@box> X-Mailer: git-send-email 2.23.0.162.g0b9fbb3734-goog Subject: [PATCH v2 1/4] 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.23.0.162.g0b9fbb3734-goog