From patchwork Mon Feb 17 11:28:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenqiwu X-Patchwork-Id: 11386159 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 D3E1314E3 for ; Mon, 17 Feb 2020 11:28:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9C982207FD for ; Mon, 17 Feb 2020 11:28:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qWqewf9Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C982207FD 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 D83E06B0005; Mon, 17 Feb 2020 06:28:28 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D35956B0006; Mon, 17 Feb 2020 06:28:28 -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 C71CD6B0007; Mon, 17 Feb 2020 06:28:28 -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 AFD796B0005 for ; Mon, 17 Feb 2020 06:28:28 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5CFD0180AD815 for ; Mon, 17 Feb 2020 11:28:28 +0000 (UTC) X-FDA: 76499395896.24.frogs12_842215ee32037 X-Spam-Summary: 2,0,0,c488962a59834f1b,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: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.215.194:@gmail.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,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: frogs12_842215ee32037 X-Filterd-Recvd-Size: 4360 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Mon, 17 Feb 2020 11:28:27 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id g3so8836288pgs.11 for ; Mon, 17 Feb 2020 03:28:27 -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=+Gunm0EzSEYNdAPlzP2cjo0QoZvlRYd/SYr/gqtUA8w=; b=qWqewf9Z9beQMT/4vFPw4LE1Kxq178mA07BE/o2LfZslDlZAVXUE+QF4jiiBWQyoJd ZXuBrCfFuS1OPZhEMXet1OWkVz9lyZwNN03fqRMGnpZ3Skj5QymuuF34kjgdOOInTrh7 k+ENI/dlHCf5n7IaciW6koj0q4s+x/SP3H4dUkQUv/1+3dgVLk+dU7ZnhEL7NOg3Dui7 rd0YyptjQtSi94dorSufGExUtmQxXlcVfWVefF+Y8+tt1lSp6pDsygV8WyIdTga62+Wo fFqDr3/S/0zgC4BESciSUjxGXX6qcErs6yKsao81c5728pJ+VB1GnMoBuDCO2+8fZZ5E STMA== 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=+Gunm0EzSEYNdAPlzP2cjo0QoZvlRYd/SYr/gqtUA8w=; b=jpKHKbFlzl1SKOX36LbQqlTfUDzP6KKN7HTZaMiaaYXnOkrDtQLivmBeCHUwXkNZa+ 5hZr9ViJ65sMe8gfqMRpxDK9A2UgWEkLdVMqSBVPBEzsr+TS8MKD5U2QVuF6dzFMBhYH U3yOvT/JGN4DNQPc9rFuRCSwV8RtyjZ04QIoOuxOHANBJtdkQBRcM9gy8F/CYTRz1V4Q XuLqh5+5ZNzBJON36lFerj0CQZvv/tf6KyiOtlrlkjc/hs63Ypwhz7Mk0DpB8a1aBb/p ZY56wg+XML7b93qcF5QYSI2VkK2SMpRHif/QniG29yVtG4XAxYWGn+gctByKy3FxE8BR cSVA== X-Gm-Message-State: APjAAAW7ocvKA+t/efgSrzWR53bzt5320upg0/kejoKX7aLJSqN7uDdq SpX9DJn+9vSZw3W5JXyWtZY= X-Google-Smtp-Source: APXvYqyIFmW+/vFRm+zZ4orO+EwTPf6ZPJqtSolLJBPpF40CXZZ2Um4cm5PP+WdmSIqnrrKY2qAV1g== X-Received: by 2002:a17:90a:20c4:: with SMTP id f62mr20120027pjg.70.1581938906731; Mon, 17 Feb 2020 03:28:26 -0800 (PST) Received: from localhost ([43.224.245.179]) by smtp.gmail.com with ESMTPSA id b3sm109913pft.73.2020.02.17.03.28.25 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 17 Feb 2020 03:28:26 -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] mm: slub: use slub_cpu_partial() and slub_set_cpu_partial() APIs Date: Mon, 17 Feb 2020 19:28:22 +0800 Message-Id: <1581938902-18383-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 --- 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 }