Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1992485ybe; Thu, 12 Sep 2019 02:48:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLq8ufFfmoy2hReYjV6Q9xAViAo5XenEOait57/hOcz5F7F2HGAwzn7YomZYi/rJok4JcB X-Received: by 2002:a50:f41a:: with SMTP id r26mr18833569edm.300.1568281730609; Thu, 12 Sep 2019 02:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568281730; cv=none; d=google.com; s=arc-20160816; b=JIhq8b6NX9+aT4d5PvxqiNo9sRZreLoHQV2Qjh2p/P64zO/a9xyERbQBGQ+0/aAVVy SIp+n9fHciSCCxzDozUUaOZTJEg+A5axKGvxJ42UkKVf2gCgsZN7AZSU7K9k1gw3sLuV 63NU4AHr9cG41oLAk9CX87iPQU4izqHXvLLHLIEql4sHbyNBaa3BeUqoTSlE58FUEUvS vu1+y9fict+AJfxK3AXp6WRElP9iI6fIGXPocEVRUfMi3A/Ew7TICe4l9xr0OgtXC8Ar 2DxsAsbnv0tNon+1NuHRlCSxib9Dn97sop7q/0f/VwlFjY36blGKb+UrwRtYyVLcHL64 L1Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+UyKiSlCaUkZGSuO0Sn5mI0OYBngHSXLKAH/562lIqI=; b=ddMhRWpAw/nAYy2l+ZvuTu5cdW5XxjPAr4hNspL1OmLvTeO4F2HUYDslJg8Np78cbg 3m/svwj5VsM0OTua72cERJvld/MXWyGODn9OWgfAVtxb3i4n0N1cGWf8acTPHbxxi2lT hYpOkBrL71czJlLy/wun5/3my+pkc9yTXJFocBEUUyfk6KrcabuGY4u2JiNeUEHVeqDW UJLsSDz5c8eYly6pz7UCm7PfhJWVtbqSxeNVPU0bzs+O3og+8OkTF+uonH5ripL5eaSR CwA9tY6IVDgVwIFF/f0VvV9hZ8QIgbXK5lj9eC85W99WwiKRkkKavJwOAyvSHzm3+7lp 8TxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=aXpDJ9aB; 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 j28si16172473eda.161.2019.09.12.02.48.26; Thu, 12 Sep 2019 02:48:50 -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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=aXpDJ9aB; 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 S1730811AbfILJqZ (ORCPT + 99 others); Thu, 12 Sep 2019 05:46:25 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:44658 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730237AbfILJqY (ORCPT ); Thu, 12 Sep 2019 05:46:24 -0400 Received: by mail-ed1-f66.google.com with SMTP id p2so22159087edx.11 for ; Thu, 12 Sep 2019 02:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=+UyKiSlCaUkZGSuO0Sn5mI0OYBngHSXLKAH/562lIqI=; b=aXpDJ9aB0wt3TGU0/ZL7E4RmOYJxeN5X/S5JG56aeGrcXRjwWCzWTem0AkaoNFe990 bbE9Omc+2tzXG9k75Ev0aAclSuz8BCC9xlRjcZY5SkuudR4RcJLpGcGK6TqZvqbiSrOn W0OEkpagpUWEmj45mgjtp27+YzCfGbvHnPUtQXLjRci0ORz4NZco6SDSjS6kxxeuNqf8 dAMhtWIDh5TXG8Ti3lTRUNNrp3i/dODe9ejjJmlbJuL5Ie7yK+TxFSC20cIM2TwFaTV/ KPVnBfabA9Ld+Zvd1kdKeLfKUdaRigCO94b1SCtPgCv0zksO1KPMyWvI+eaXpEFpfNPB gSjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=+UyKiSlCaUkZGSuO0Sn5mI0OYBngHSXLKAH/562lIqI=; b=NpUn1JXr31RCtNTIhbOXD8K3z18KEe36hEFl1tjmz3A7h/6Cmeu9QKJnBCYsuHervD GHu0MFIqv5uQ+y/+qRgpIMlGBPDxfmmV4fE+nb7KOFhJ2HHfhDsmcW/sQVS3lDbqevUW FrwLMq4V0xkx5QlP68RElwNsI35pqYxp1zv7N7FRnVnWjWPkJD5+bHhTAHrRfuNhZTor 9XPUW//bh5EO8rfVmXXA2PgTTTGoexkrz+EBP6peS50xUBKIzIX+YGFV3evPLIexd3mW 6wHp7cHqIVX7G3lIZzflH4ABztJNawAceKdhfEzAWEf53hiprW+Pj9rAL4UkzwJpl3/9 Tyew== X-Gm-Message-State: APjAAAW1EqK8V+Px4aDfXsWiCrydHJVC/KSChaumtuC3JPM23FozBLkx EgKmJ+EgQmDrHvqhy/dFbN/V9g== X-Received: by 2002:aa7:d899:: with SMTP id u25mr39791190edq.289.1568281582725; Thu, 12 Sep 2019 02:46:22 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id t21sm2728489ejf.27.2019.09.12.02.46.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Sep 2019 02:46:22 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 3884C100B4A; Thu, 12 Sep 2019 12:46:23 +0300 (+03) Date: Thu, 12 Sep 2019 12:46:23 +0300 From: "Kirill A. Shutemov" To: Yu Zhao Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Tetsuo Handa , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/4] mm: clean up validate_slab() Message-ID: <20190912094623.fn6qdefrnnskdai5@box> References: <20190912004401.jdemtajrspetk3fh@box> <20190912023111.219636-1-yuzhao@google.com> <20190912023111.219636-2-yuzhao@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190912023111.219636-2-yuzhao@google.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 11, 2019 at 08:31:09PM -0600, Yu Zhao wrote: > The function doesn't need to return any value, and the check can be > done in one pass. > > There is a behavior change: before the patch, we stop at the first > invalid free object; after the patch, we stop at the first invalid > object, free or in use. This shouldn't matter because the original > behavior isn't intended anyway. > > Signed-off-by: Yu Zhao > --- > mm/slub.c | 21 ++++++++------------- > 1 file changed, 8 insertions(+), 13 deletions(-) > > diff --git a/mm/slub.c b/mm/slub.c > index 62053ceb4464..7b7e1ee264ef 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -4386,31 +4386,26 @@ static int count_total(struct page *page) > #endif > > #ifdef CONFIG_SLUB_DEBUG > -static int validate_slab(struct kmem_cache *s, struct page *page, > +static void validate_slab(struct kmem_cache *s, struct page *page, > unsigned long *map) > { > void *p; > void *addr = page_address(page); > > - if (!check_slab(s, page) || > - !on_freelist(s, page, NULL)) > - return 0; > + if (!check_slab(s, page) || !on_freelist(s, page, NULL)) > + return; > > /* Now we know that a valid freelist exists */ > bitmap_zero(map, page->objects); > > get_map(s, page, map); > for_each_object(p, s, addr, page->objects) { > - if (test_bit(slab_index(p, s, addr), map)) > - if (!check_object(s, page, p, SLUB_RED_INACTIVE)) > - return 0; > - } > + u8 val = test_bit(slab_index(p, s, addr), map) ? > + SLUB_RED_INACTIVE : SLUB_RED_ACTIVE; Proper 'if' would be more readable. Other than that look fine to me. > > - for_each_object(p, s, addr, page->objects) > - if (!test_bit(slab_index(p, s, addr), map)) > - if (!check_object(s, page, p, SLUB_RED_ACTIVE)) > - return 0; > - return 1; > + if (!check_object(s, page, p, val)) > + break; > + } > } > > static void validate_slab_slab(struct kmem_cache *s, struct page *page, > -- > 2.23.0.162.g0b9fbb3734-goog > -- Kirill A. Shutemov