From patchwork Mon Jul 9 08:40:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10513993 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 863D3603D7 for ; Mon, 9 Jul 2018 08:40:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E97728A74 for ; Mon, 9 Jul 2018 08:40:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 621F628A78; Mon, 9 Jul 2018 08:40:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EBC228A74 for ; Mon, 9 Jul 2018 08:40:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 578F46B02A6; Mon, 9 Jul 2018 04:40:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 502E56B02A8; Mon, 9 Jul 2018 04:40:27 -0400 (EDT) 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 3A2856B02A9; Mon, 9 Jul 2018 04:40:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f199.google.com (mail-qk0-f199.google.com [209.85.220.199]) by kanga.kvack.org (Postfix) with ESMTP id 055416B02A6 for ; Mon, 9 Jul 2018 04:40:27 -0400 (EDT) Received: by mail-qk0-f199.google.com with SMTP id l186-v6so16156851qkc.22 for ; Mon, 09 Jul 2018 01:40:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding:spamdiagnosticoutput :spamdiagnosticmetadata; bh=M2ESCccgvwPXUBWqT/nZctizvXUAPLunCLN1xW2YGpk=; b=sqZu5jZpWymDSuBdKgStuuHDAHtOJpaKizOWitVtUT60DIEfsE36tHVGToIXWR0QqP psV33Le5iB1wj/hgAARJRfp6ApHjYEmuuznSt8gAWwO+crbCaEn4KLRIKai9pccDOaBr MAWAdpZQcxr5hfOWP94EgZsjWizXYPanC31Be9YhKBAlgoIrXIUq3AMrs2/P3G7sYtgr eqqo+BPvTzQfUPmPqu85iHc9qr9qy5F/ib5EwoCkguOMfo2NT7YUhRBNQzKjiVKF/VTK uZiPScMc9brVCK+M94J3mr8Gcyrvr3WZBt7Pij9GHHXXnNWLSXAgkwX7RpNFPfV/aM/G VXPQ== X-Gm-Message-State: APt69E1LwMRI2MevttB6QBGWzcC5DIqAOuZlLduWTB2o5xxRR9+eZU1y 5kDO2DGtmfN4ylpI3XO4D0UAvIFAsuX7UzwOD77l+m+HnM0Y0AWxQRhreOD1kyXqlk5HsifBYrh 2j5+Bh2Ua6XIGN1v/HO2sy9eNzaCRcadM5ubSfsbHGCwVVqReFsbA0zNuiIx4AP0RYA== X-Received: by 2002:a0c:a8cc:: with SMTP id h12-v6mr16867268qvc.161.1531125626776; Mon, 09 Jul 2018 01:40:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdkWck3Z3ZCOmZOqRuos8Sg37AGl06RkwJQ9+CFN/tMQgmdldYZfufhQdAk/087zOjw34Ps X-Received: by 2002:a0c:a8cc:: with SMTP id h12-v6mr16867244qvc.161.1531125625937; Mon, 09 Jul 2018 01:40:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531125625; cv=none; d=google.com; s=arc-20160816; b=TnKj+PkZfcD1n0HRXe4x52UcVVHMf1tfyBXEdIXyHrRp4ROi7vCBChN7XmgI4CtmZf PAOfrplejhzDkDqAIUTnYDR4Oiek2UfpPZq7CacljOj+WIhnJA7oYGjdZXWPD4pm5DN/ jNmvuihxWWqhdtkryTXQihnHebjh4Vbs3Lbz04n842VM5qGEykUt+Wop7LeCtTBtz18s w+GSn6Zge/XsX1tV9IKTxZ+ZBTGDllVVO9E23nx4FESeQB8QnmwZiDDIn88VIuNGAbf+ uTf6XTO/p9zCWpCMFbl8wMYPBGJAM05oRhMgt3ufVPE839K7iu9Yd8LA5rT4w/xTpgSX hNDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=spamdiagnosticmetadata:spamdiagnosticoutput :content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:to:from:subject:dkim-signature :arc-authentication-results; bh=M2ESCccgvwPXUBWqT/nZctizvXUAPLunCLN1xW2YGpk=; b=PkgsHe9Dw+quxONN5Sl7RVhlYxgSTNSutetSZc6Z8FYjDAjDr5HQsoHrvYvT8N9rAu 1OPUe0UgfFppmAlCEnNjr8brOZv5VMehVK0hMhI6AyVfN430gdyQMWNgwm9fJVkFiCxc YBsxGizgR/3ki3UN5Of4GkH5H/hNF1o59+DKqyTvLyOKFyva3pYp3a0RRd6OFjJ0qxGW CjKdVIffi1KQURYYRFDZFiubRIM9U77Vszqoqv9R80lO8JHqBsoEQ0fD5lTvAA3SlBCY WDpv42G2qV/TEou2RdrRDPhN1USQb8+YhmcfMBokr/shdReUmpgSq1+hyKfvUUz9uUzW SgUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=bPVSpLIQ; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 104.47.2.112 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0112.outbound.protection.outlook.com. [104.47.2.112]) by mx.google.com with ESMTPS id a132-v6si4275452qkg.106.2018.07.09.01.40.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Jul 2018 01:40:25 -0700 (PDT) Received-SPF: pass (google.com: domain of ktkhai@virtuozzo.com designates 104.47.2.112 as permitted sender) client-ip=104.47.2.112; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=bPVSpLIQ; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 104.47.2.112 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M2ESCccgvwPXUBWqT/nZctizvXUAPLunCLN1xW2YGpk=; b=bPVSpLIQJ7w4m5FnvZ7BiYAs0NH9Dt1Kw9zHrO/4H6R4D4xwb8C0ab5s8r+5KHdbei4rT/sBz1Z7pDGijel+m+zjBNCTx4w8CxPpqBIrggv35HeqYhey6ZI7XniAh18PGHKRPfSlxl4BycFIHtuzBnW4g+93qNCrkwgHk050gh8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from localhost.localdomain (185.231.240.5) by HE1PR0801MB1337.eurprd08.prod.outlook.com (2603:10a6:3:39::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.19; Mon, 9 Jul 2018 08:40:21 +0000 Subject: [PATCH v9 17/17] mm: Clear shrinker bit if there are no objects related to memcg From: Kirill Tkhai To: vdavydov.dev@gmail.com, shakeelb@google.com, viro@zeniv.linux.org.uk, hannes@cmpxchg.org, mhocko@kernel.org, tglx@linutronix.de, pombredanne@nexb.com, stummala@codeaurora.org, gregkh@linuxfoundation.org, sfr@canb.auug.org.au, guro@fb.com, mka@chromium.org, penguin-kernel@I-love.SAKURA.ne.jp, chris@chris-wilson.co.uk, longman@redhat.com, minchan@kernel.org, ying.huang@intel.com, mgorman@techsingularity.net, jbacik@fb.com, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, lirongqing@baidu.com, aryabinin@virtuozzo.com, akpm@linux-foundation.org, ktkhai@virtuozzo.com Date: Mon, 09 Jul 2018 11:40:17 +0300 Message-ID: <153112561772.4097.11011071937553113003.stgit@localhost.localdomain> In-Reply-To: <153112469064.4097.2581798353485457328.stgit@localhost.localdomain> References: <153112469064.4097.2581798353485457328.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: VI1PR08CA0116.eurprd08.prod.outlook.com (2603:10a6:800:d4::18) To HE1PR0801MB1337.eurprd08.prod.outlook.com (2603:10a6:3:39::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1fce10e8-be79-4252-4fb1-08d5e5779cfc X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:HE1PR0801MB1337; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1337; 3:gs+NfBcJfK17zUxcck6h+OQIkanhYBTdldrl7wbaZ1mhpKcqIfZ00pu6u+lZSScYDbcfpfChcS5kkIyr8Ou8hjI0K2x+0+8JCL4UHx/xg7yfN1X3BN3NHkFaqVGhtq22DNvcJC0GdGfhT+wnL8/zLz72dbJ04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y274BrQWkrCUITe2l+9O5Dl4C4uCHbiIzPGerSjlb5MSOjT2BOnnu9u+PrJtdgwEyQXISg3Vfp+egUE6NsnFKECriElNQholWAtjlZ2xxbuLa6mn8tnD4qGcDir85ZzzJx2rNkbbWbZ7SeaWFSwp3zMr1WWUqPrGTVwApizFradFNVGa2z; 4:6iZcTdeFx+v29mQ1mRivO6cXpg9A94OC3AsQWif2tIXu/29HpuWBTbbrN6U9BGNyK+EwueD0/OfHy//ZrJy7yqVYIDSsw0YfEVlZzBDuXtLAXfNRE9yVRmgwsLcTes2fmAaEsJtznakkpw2WmSIMa1Jbi1ZqADBh3CnptuWOOahnCGj74j2SpQKK+YllBFOwGHxHEbJhS75lt57ZT/OLd7lF6y2BEoAlf1cQWcWCoRJFwri965Ed7Z6JX5CtI7Vrsg0FdB8M61PNTsgmb6tdfVPc5JAy8FAAKhayS+FXsT65Z5Z64bSOF4edzhPqWRruMQLwZzY12qjuloj7cPOhLrPkPO2O5Cf2UBdSGVpgGMO4OVoEbuRbHSsTZXr/wzmdfQl/vfknUcv0ZR25BsVRzKw4ezcKjCA/N5/n+gLYfmM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(20558992708506)(85827821059158)(211936372134217)(153496737603132); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(3231311)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:HE1PR0801MB1337; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0801MB1337; X-Forefront-PRVS: 07283408BE X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(396003)(39850400004)(136003)(376002)(366004)(346002)(199004)(189003)(9686003)(14444005)(61506002)(68736007)(230700001)(11346002)(446003)(956004)(476003)(8936002)(53936002)(55016002)(2906002)(47776003)(486006)(81166006)(81156014)(66066001)(7736002)(3846002)(305945005)(6116002)(58126008)(23676004)(2486003)(6506007)(386003)(8676002)(76176011)(316002)(52116002)(478600001)(106356001)(105586002)(50466002)(97736004)(16526019)(86362001)(25786009)(103116003)(7416002)(39060400002)(5660300001)(33896004)(7696005)(26005)(186003)(6666003)(921003)(1121003); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0801MB1337; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA4MDFNQjEzMzc7MjM6NVdkb1hDdUkxOXA0ZkhPQXpNanN3MlA3?= =?utf-8?B?SjRocmsrZCtxcHU4YWhyTUVBbVV4TUErMm5Lc2lvYnJUMmV6NEJ6aExJRjg3?= =?utf-8?B?RHJJaXlSQkpoNXduQk5KMCs0V2U3MHFxdHk2Z0VXYWhHTjlUQXVGMThNSzFV?= =?utf-8?B?NHJEVCtmWFhHeTZWdURCSHppclZmbDNMMUtoSFhpVEJYNElHTzdoTGxCc2Er?= =?utf-8?B?VXFLVlFOTXRsMDV2WW5kS0hHMUR1WHFYcDVvVGlwTUZKazJYNkFUbjZMTjVz?= =?utf-8?B?Rk9CdnNHUm1ldFdrbEJ2eVpsVHJVTFd6VnJoUStKSWFDbWNwb0IxMXJCM1Na?= =?utf-8?B?ckFWbkdobXd1SlY0dU9OdTFyYTROV3hZU1lBV0daUTFCNlEyUEh5a3FwRkFT?= =?utf-8?B?N0pNUFU0cWhwRDBRRHE0SjgxRnJETnQzc0ltWkFRNFROR1BGRmJEWklRQ29t?= =?utf-8?B?R2lUa2xMbnFWZXc3RnYyZmtCVTYva2k5WWdKeXQranVGWUkwejZjRGYzU2ww?= =?utf-8?B?T3BKblkyaUE4dERsOW8ralNtQlRK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kx9kJZNbspneHJgAnC9PNgjp2IMegi0V6FYDxnXMVft2nSqK224eA4aqn4tvJnBH5bCAxWERkuVt3DG9M3xvYlL+PmeHRKqFFS/nSzBZzmRqLnC42eUrCJZl8RZTVzNHwVMzzH997thv4fl2Q4R1NxWQ6dc1n0Acn7Dttzm9/b7kzrK3TKx4Ns21UMEdV5zf/6IAQ==; 5:5aiiiR1EBLk10Hs3GSPeDaxpbqdy6cwBey67KJ95SKtmDVaC41+2E6NCwGk58QEU7DR7Q4zgEnzIki9qkDDO6qMoQbvX/rYYoHdoz6L69sN7WG80spSa7t4sRHp5XlF7fBNRVvYleMEZEjul2tosC2wN7S0O2BdY0iylkJOrYBE=; 24:Vx6tJJzxSWAPdnArOipjJ6AQShvelg/yJELhXJ5zv73mh24uoQjyGdwA1jIm107Qq+5zbKm4Ba1LZV47XRF/KsmtPV8r7dd8ukvnvUwKUsU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1337; 7:IiqUhIpFKnaP0xgIxhtHXESGWxjG0EdRXBwJCugG3gx1xzagcSoL8R3mpRIaOHcBTdSjKCFGNaelvPd3iCvnyM+TCaFfbpsqxSc0oeOVHKusjnZyVATh0FsEhuVCVcl3ykdZMzRJb/iiy6tUdGjm8AJn0J/BrwESD3N15V3tX/L4/24LtMZ2wNEIe0QswoaWXIrNpgnNyb2yzqVvSb/DzsFUhT5WDdr+hmcacB3p1gRCyBfo1duxU30E09QdwOLN; 20:lcylpBA/ShUKeIg9ogaQp8t2MpwRpA8rpZOkjINMTzCtAmybMARFTbr6fA9zkOYnJV9SKAU7cdN3S3ffMp/HEoo3aVFft+Svw6F58HrTfTVAd/nsZb3TDIzjuoWCTzJavt+zBPRoZ06KKH2TCCnlpnPtXjtL+1fATv4tGUFO1VU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2018 08:40:21.2160 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fce10e8-be79-4252-4fb1-08d5e5779cfc X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1337 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: X-Virus-Scanned: ClamAV using ClamSMTP To avoid further unneed calls of do_shrink_slab() for shrinkers, which already do not have any charged objects in a memcg, their bits have to be cleared. This patch introduces a lockless mechanism to do that without races without parallel list lru add. After do_shrink_slab() returns SHRINK_EMPTY the first time, we clear the bit and call it once again. Then we restore the bit, if the new return value is different. Note, that single smp_mb__after_atomic() in shrink_slab_memcg() covers two situations: 1)list_lru_add() shrink_slab_memcg list_add_tail() for_each_set_bit() <--- read bit do_shrink_slab() <--- missed list update (no barrier) set_bit() do_shrink_slab() <--- seen list update This situation, when the first do_shrink_slab() sees set bit, but it doesn't see list update (i.e., race with the first element queueing), is rare. So we don't add before the first call of do_shrink_slab() instead of this to do not slow down generic case. Also, it's need the second call as seen in below in (2). 2)list_lru_add() shrink_slab_memcg() list_add_tail() ... set_bit() ... ... for_each_set_bit() do_shrink_slab() do_shrink_slab() clear_bit() ... ... ... list_lru_add() ... list_add_tail() clear_bit() set_bit() do_shrink_slab() The barriers guarantees, the second do_shrink_slab() in the right side task sees list update if really cleared the bit. This case is drawn in the code comment. [Results/performance of the patchset] After the whole patchset applied the below test shows signify increase of performance: $echo 1 > /sys/fs/cgroup/memory/memory.use_hierarchy $mkdir /sys/fs/cgroup/memory/ct $echo 4000M > /sys/fs/cgroup/memory/ct/memory.kmem.limit_in_bytes $for i in `seq 0 4000`; do mkdir /sys/fs/cgroup/memory/ct/$i; echo $$ > /sys/fs/cgroup/memory/ct/$i/cgroup.procs; mkdir -p s/$i; mount -t tmpfs $i s/$i; touch s/$i/file; done Then, 5 sequential calls of drop caches: $time echo 3 > /proc/sys/vm/drop_caches 1)Before: 0.00user 13.78system 0:13.78elapsed 99%CPU 0.00user 5.59system 0:05.60elapsed 99%CPU 0.00user 5.48system 0:05.48elapsed 99%CPU 0.00user 8.35system 0:08.35elapsed 99%CPU 0.00user 8.34system 0:08.35elapsed 99%CPU 2)After 0.00user 1.10system 0:01.10elapsed 99%CPU 0.00user 0.00system 0:00.01elapsed 64%CPU 0.00user 0.01system 0:00.01elapsed 82%CPU 0.00user 0.00system 0:00.01elapsed 64%CPU 0.00user 0.01system 0:00.01elapsed 82%CPU The results show the performance increases at least in 548 times. Shakeel Butt tested this patchset with fork-bomb on his configuration: > I created 255 memcgs, 255 ext4 mounts and made each memcg create a > file containing few KiBs on corresponding mount. Then in a separate > memcg of 200 MiB limit ran a fork-bomb. > > I ran the "perf record -ag -- sleep 60" and below are the results: > > Without the patch series: > Samples: 4M of event 'cycles', Event count (approx.): 3279403076005 > + 36.40% fb.sh [kernel.kallsyms] [k] shrink_slab > + 18.97% fb.sh [kernel.kallsyms] [k] list_lru_count_one > + 6.75% fb.sh [kernel.kallsyms] [k] super_cache_count > + 0.49% fb.sh [kernel.kallsyms] [k] down_read_trylock > + 0.44% fb.sh [kernel.kallsyms] [k] mem_cgroup_iter > + 0.27% fb.sh [kernel.kallsyms] [k] up_read > + 0.21% fb.sh [kernel.kallsyms] [k] osq_lock > + 0.13% fb.sh [kernel.kallsyms] [k] shmem_unused_huge_count > + 0.08% fb.sh [kernel.kallsyms] [k] shrink_node_memcg > + 0.08% fb.sh [kernel.kallsyms] [k] shrink_node > > With the patch series: > Samples: 4M of event 'cycles', Event count (approx.): 2756866824946 > + 47.49% fb.sh [kernel.kallsyms] [k] down_read_trylock > + 30.72% fb.sh [kernel.kallsyms] [k] up_read > + 9.51% fb.sh [kernel.kallsyms] [k] mem_cgroup_iter > + 1.69% fb.sh [kernel.kallsyms] [k] shrink_node_memcg > + 1.35% fb.sh [kernel.kallsyms] [k] mem_cgroup_protected > + 1.05% fb.sh [kernel.kallsyms] [k] queued_spin_lock_slowpath > + 0.85% fb.sh [kernel.kallsyms] [k] _raw_spin_lock > + 0.78% fb.sh [kernel.kallsyms] [k] lruvec_lru_size > + 0.57% fb.sh [kernel.kallsyms] [k] shrink_node > + 0.54% fb.sh [kernel.kallsyms] [k] queue_work_on > + 0.46% fb.sh [kernel.kallsyms] [k] shrink_slab_memcg Signed-off-by: Kirill Tkhai Acked-by: Vladimir Davydov Tested-by: Shakeel Butt --- mm/memcontrol.c | 2 ++ mm/vmscan.c | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 70881f04775d..bd1e3823236f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -430,6 +430,8 @@ void memcg_set_shrinker_bit(struct mem_cgroup *memcg, int nid, int shrinker_id) rcu_read_lock(); map = rcu_dereference(memcg->nodeinfo[nid]->shrinker_map); + /* Pairs with smp mb in shrink_slab() */ + smp_mb__before_atomic(); set_bit(shrinker_id, map->map); rcu_read_unlock(); } diff --git a/mm/vmscan.c b/mm/vmscan.c index 8199e1b9a204..93fdd0375b64 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -596,8 +596,30 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, continue; ret = do_shrink_slab(&sc, shrinker, priority); - if (ret == SHRINK_EMPTY) - ret = 0; + if (ret == SHRINK_EMPTY) { + clear_bit(i, map->map); + /* + * After the shrinker reported that it had no objects to + * free, but before we cleared the corresponding bit in + * the memcg shrinker map, a new object might have been + * added. To make sure, we have the bit set in this + * case, we invoke the shrinker one more time and reset + * the bit if it reports that it is not empty anymore. + * The memory barrier here pairs with the barrier in + * memcg_set_shrinker_bit(): + * + * list_lru_add() shrink_slab_memcg() + * list_add_tail() clear_bit() + * + * set_bit() do_shrink_slab() + */ + smp_mb__after_atomic(); + ret = do_shrink_slab(&sc, shrinker, priority); + if (ret == SHRINK_EMPTY) + ret = 0; + else + memcg_set_shrinker_bit(memcg, nid, i); + } freed += ret; if (rwsem_is_contended(&shrinker_rwsem)) {