Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2707439imc; Tue, 12 Mar 2019 22:23:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8FyR/GMy+vD7/CXwwT/MdUABmBMLUe/JPQwjQxawAKj6VPjDIgDOI33VMAWlinilU9glQ X-Received: by 2002:a63:c204:: with SMTP id b4mr38223485pgd.335.1552454608061; Tue, 12 Mar 2019 22:23:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552454608; cv=none; d=google.com; s=arc-20160816; b=sSloFx24Rql9LD58qkerrpz5RMulO6TWGRzxEsdpSRHCq6+bs90a3VK6dTwoQLzUqL CoYmlZ+xfDKfftx/jhK2tWpMoygLKlfbIcS8Pv+fks9ZT5LwVSh8v76W+W2YGsZRF9ks I/3nTJDTOhmaTwvxkF2yhbKtxPiYDcJMBSTxPid78pmnFoDi+aRmRJyz/2tE1zHpokOu 2kfEdSvN0MpAtzxmNlNM07VyDoBiK9yNWg4R9BoUXEgX9nye1DNqYQSEeUV2mIWuww+K 5vHfP1LIz9Nin9HjFBufgaeQ2sIlXHE/HQA3LYoruXN33v1WWXUVIBVl2bt09WKzrIkd /Q1g== 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 :dkim-signature; bh=aR78W31q72vxmgugCUO4zRYVwt/hNV8R2x/8ymYFgIU=; b=qmuEhjckZWhrJu9aDp4WIjjYInokns7O3s+ObadwqHf0zE2FM2TT44QaLhk15wUYyM Sqz3h3xrtn/ewALSSUKcIOXMNR/gCCpVR2Lzz/IgVGqNnRkxo60whckKk7zRSI/70VIq IjKxmFdFxVaaTYc023D9JBVDQpYQ+mxpsHd5OTYU9tv7qPFHe7cZUDYPZldB3dD6zR+h nipmn5+HPAtjDpu8SieL+nU6mjZ/DKD4GCC3MkJzEatl4R0iuv7IZOSiuiqztgpdJ4B7 Zd+nrG1/yRN9G3EKxQjt/7EBNtSkSb4UqAT2hBCw81qMSz+kdHITUelP5azbJWNAIahm AZIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Y59tExhx; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f21si9721517plr.297.2019.03.12.22.23.11; Tue, 12 Mar 2019 22:23:28 -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=@messagingengine.com header.s=fm2 header.b=Y59tExhx; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726928AbfCMFVY (ORCPT + 99 others); Wed, 13 Mar 2019 01:21:24 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:45735 "EHLO wout2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725821AbfCMFVW (ORCPT ); Wed, 13 Mar 2019 01:21:22 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 9D02838BD; Wed, 13 Mar 2019 01:21:20 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 13 Mar 2019 01:21:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=aR78W31q72vxmgugCUO4zRYVwt/hNV8R2x/8ymYFgIU=; b=Y59tExhx GKNS4b5q5bZQhE8JfLu/yue+mnCE/qtxShZS6ONFIZCadUJmGwilY3O+AiZOo73g b6XQskb8KQcazK1o0Z9CCq5rHVGJv3fk4KfTwZWAw+cnC2Oxw9bSEGI9cdQKd8Rm BnlrynlD0UX/DNKn7kPHai/+kIufKApqtMtsEUlV/3i9jLyxk5jHjuykM7Z39/v6 Y0TybJ/0+fOy8/+josus7cXyZ0N4e2lV/CTWgnkwDCDLcMnKmE6LorOlGsy7TOWP 4vpxWGoWdYSYKjL18kPzkOXOgj0DA3OrHpOJNR+2y5hl1bx/3vrY9alD0UVeLpOD 079JXKsVGxtmCQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrgeelgdekudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhn ucevrdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkph epuddvgedrudeiledrvdefrddukeegnecurfgrrhgrmhepmhgrihhlfhhrohhmpehtohgs ihhnsehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpedv X-ME-Proxy: Received: from eros.localdomain (124-169-23-184.dyn.iinet.net.au [124.169.23.184]) by mail.messagingengine.com (Postfix) with ESMTPA id A7752E427E; Wed, 13 Mar 2019 01:21:16 -0400 (EDT) From: "Tobin C. Harding" To: Andrew Morton Cc: "Tobin C. Harding" , Roman Gushchin , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/5] slob: Use slab_list instead of lru Date: Wed, 13 Mar 2019 16:20:29 +1100 Message-Id: <20190313052030.13392-5-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190313052030.13392-1-tobin@kernel.org> References: <20190313052030.13392-1-tobin@kernel.org> 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 Currently we use the page->lru list for maintaining lists of slabs. We have a list_head in the page structure (slab_list) that can be used for this purpose. Doing so makes the code cleaner since we are not overloading the lru list. The slab_list is part of a union within the page struct (included here stripped down): union { struct { /* Page cache and anonymous pages */ struct list_head lru; ... }; struct { dma_addr_t dma_addr; }; struct { /* slab, slob and slub */ union { struct list_head slab_list; struct { /* Partial pages */ struct page *next; int pages; /* Nr of pages left */ int pobjects; /* Approximate count */ }; }; ... Here we see that slab_list and lru are the same bits. We can verify that this change is safe to do by examining the object file produced from slob.c before and after this patch is applied. Steps taken to verify: 1. checkout current tip of Linus' tree commit a667cb7a94d4 ("Merge branch 'akpm' (patches from Andrew)") 2. configure and build (select SLOB allocator) CONFIG_SLOB=y CONFIG_SLAB_MERGE_DEFAULT=y 3. dissasemble object file `objdump -dr mm/slub.o > before.s 4. apply patch 5. build 6. dissasemble object file `objdump -dr mm/slub.o > after.s 7. diff before.s after.s Use slab_list list_head instead of the lru list_head for maintaining lists of slabs. Reviewed-by: Roman Gushchin Signed-off-by: Tobin C. Harding --- mm/slob.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/slob.c b/mm/slob.c index 307c2c9feb44..ee68ff2a2833 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -112,13 +112,13 @@ static inline int slob_page_free(struct page *sp) static void set_slob_page_free(struct page *sp, struct list_head *list) { - list_add(&sp->lru, list); + list_add(&sp->slab_list, list); __SetPageSlobFree(sp); } static inline void clear_slob_page_free(struct page *sp) { - list_del(&sp->lru); + list_del(&sp->slab_list); __ClearPageSlobFree(sp); } @@ -283,7 +283,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) spin_lock_irqsave(&slob_lock, flags); /* Iterate through each partially free page, try to find room */ - list_for_each_entry(sp, slob_list, lru) { + list_for_each_entry(sp, slob_list, slab_list) { #ifdef CONFIG_NUMA /* * If there's a node specification, search for a partial @@ -297,7 +297,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) continue; /* Attempt to alloc */ - prev = sp->lru.prev; + prev = sp->slab_list.prev; b = slob_page_alloc(sp, size, align); if (!b) continue; @@ -323,7 +323,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) spin_lock_irqsave(&slob_lock, flags); sp->units = SLOB_UNITS(PAGE_SIZE); sp->freelist = b; - INIT_LIST_HEAD(&sp->lru); + INIT_LIST_HEAD(&sp->slab_list); set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE)); set_slob_page_free(sp, slob_list); b = slob_page_alloc(sp, size, align); -- 2.21.0