From patchwork Wed Feb 19 02:32:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenqiwu X-Patchwork-Id: 11390279 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 3627D13A4 for ; Wed, 19 Feb 2020 02:32:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC88624656 for ; Wed, 19 Feb 2020 02:32:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B20XfkJW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC88624656 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 31FF86B0003; Tue, 18 Feb 2020 21:32:49 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2AA2F6B0006; Tue, 18 Feb 2020 21:32:49 -0500 (EST) 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 1727A6B0007; Tue, 18 Feb 2020 21:32:49 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id F04CF6B0003 for ; Tue, 18 Feb 2020 21:32:48 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 806512C89 for ; Wed, 19 Feb 2020 02:32:48 +0000 (UTC) X-FDA: 76505303616.06.unit45_52ae10e0db82a X-Spam-Summary: 2,0,0,1a0b5cb87e788265,d41d8cd98f00b204,qiwuchen55@gmail.com,:cl@linux.com:penberg@kernel.org:rientjes@google.com:iamjoonsoo.kim@lge.com:akpm@linux-foundation.org::chenqiwu@xiaomi.com,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2693:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3871:4385:5007:6261:6653:7576:7875:8603:9413:10004:11026:11658:11914:12043:12048:12114:12296:12297:12438:12517:12519:12555:12679:12895:13069:13161:13229:13311:13357:14096:14181:14384:14394:14721:21080:21444:21451:21627:21666:30012:30054,0,RBL:209.85.210.196:@gmail.com:.lbl8.mailshell.net-62.50.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,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: unit45_52ae10e0db82a X-Filterd-Recvd-Size: 4405 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Wed, 19 Feb 2020 02:32:48 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id i6so11713218pfc.1 for ; Tue, 18 Feb 2020 18:32:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=PntfFEQMoDyXYjc3UCrN3gPm9QI+1+2SMbSdmME0P4Q=; b=B20XfkJWpQvfZJcokzRm1lBa687OvDGuShNFnU4t/55WI+MZFNbjNTwNHrZvs26AL8 vs+e+sA7yDUpqjeHiP7cMsxa6Ljxv4Lmfh6f11M6fH/harL8/S596rQMOzT6jIs0lBN3 ac7wyEka2DeWna9BujKpq6H/A6ZV7In7AIMd2GFUVyukXFUxYPf1BQfHFMeD6y9d8Hqx XJbOpn2lRYgiXvFJDUDDi9jwIgV9IvgNkKLrpi+hHhgFgXz27iMsIFLLLHW+Lc/W7xvW LuwBBqT5wwRVp7EGcYfl8IS0ZrwlA//jLjygK3JMiKsEVQ+EUOkKK7qhQB/RC21NmjMG 9Izw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PntfFEQMoDyXYjc3UCrN3gPm9QI+1+2SMbSdmME0P4Q=; b=EqJHvNlHELu9aPHkqy2r1OiMBA0/0sBzbq1TZSQAN0hnx4w5TMrOu9h8WKK0yyJfwj JtfPriIetbehOdCBfRYrfhJPI8dxaAJQHquBr8EGo6Z9wcD6sWV2W5W9MOMZCpzAPU7u HOvNUxWJLiBC1TSLLa5p+w+iEThf1o72NmAoBdyN/y3h+6p9jGdNg2/k/OQ5krC08Cax J4MK99b5Pz1JtPHURAmytr7QgRaFiT8qrwdbjM/uPZSD+B7XWsy0fXxKY2SVeR43Fmi0 Sf+2K8744gvYkgnJmL6XIj/hLg/r3wGYz6RV3fQpqZWgybugJxak+/SYsiCwRsceiijW InAw== X-Gm-Message-State: APjAAAXR/9a65yPfmOrVzVx2w/BGhjI/OPdNmc4k4F64p+tVQM4bIvCO MF42pRxfzarJ7gTDjoidnXE= X-Google-Smtp-Source: APXvYqz/uyQpExy57TCt+/b59Uo5h7EEPPwcTWE4RRO3/UkxW29g121Sw1TtE/hAMjmi1zOG19TL0w== X-Received: by 2002:a63:ab04:: with SMTP id p4mr26884025pgf.37.1582079567243; Tue, 18 Feb 2020 18:32:47 -0800 (PST) Received: from localhost ([43.224.245.179]) by smtp.gmail.com with ESMTPSA id f18sm289046pgn.2.2020.02.18.18.32.46 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 18 Feb 2020 18:32:46 -0800 (PST) From: qiwuchen55@gmail.com To: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, chenqiwu Subject: [PATCH v2] mm/slub.c: replace kmem_cache->cpu_partial with wrapped APIs Date: Wed, 19 Feb 2020 10:32:42 +0800 Message-Id: <1582079562-17980-1-git-send-email-qiwuchen55@gmail.com> X-Mailer: git-send-email 1.9.1 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: From: chenqiwu There are slub_cpu_partial() and slub_set_cpu_partial() APIs to wrap kmem_cache->cpu_partial. This patch will use the two APIs to replace kmem_cache->cpu_partial in slub code. Signed-off-by: chenqiwu --- changes in v2: - rewrite the commit title. --- mm/slub.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 17dc00e..1eb888c 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2284,7 +2284,7 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain) if (oldpage) { pobjects = oldpage->pobjects; pages = oldpage->pages; - if (drain && pobjects > s->cpu_partial) { + if (drain && pobjects > slub_cpu_partial(s)) { unsigned long flags; /* * partial array is full. Move the existing @@ -2309,7 +2309,7 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain) } while (this_cpu_cmpxchg(s->cpu_slab->partial, oldpage, page) != oldpage); - if (unlikely(!s->cpu_partial)) { + if (unlikely(!slub_cpu_partial(s))) { unsigned long flags; local_irq_save(flags); @@ -3493,15 +3493,15 @@ static void set_cpu_partial(struct kmem_cache *s) * 50% to keep some capacity around for frees. */ if (!kmem_cache_has_cpu_partial(s)) - s->cpu_partial = 0; + slub_set_cpu_partial(s, 0); else if (s->size >= PAGE_SIZE) - s->cpu_partial = 2; + slub_set_cpu_partial(s, 2); else if (s->size >= 1024) - s->cpu_partial = 6; + slub_set_cpu_partial(s, 6); else if (s->size >= 256) - s->cpu_partial = 13; + slub_set_cpu_partial(s, 13); else - s->cpu_partial = 30; + slub_set_cpu_partial(s, 30); #endif }