From patchwork Wed Aug 16 08:34:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13354731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 806B7C04A94 for ; Wed, 16 Aug 2023 08:35:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE95E8D0028; Wed, 16 Aug 2023 04:35:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D98308D0001; Wed, 16 Aug 2023 04:35:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C390D8D0028; Wed, 16 Aug 2023 04:35:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B10228D0001 for ; Wed, 16 Aug 2023 04:35:39 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7F2C5803EC for ; Wed, 16 Aug 2023 08:35:39 +0000 (UTC) X-FDA: 81129309198.14.E97D2F9 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by imf29.hostedemail.com (Postfix) with ESMTP id 316BD120004 for ; Wed, 16 Aug 2023 08:35:36 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=et6Z88qK; spf=pass (imf29.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.167.177 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692174937; a=rsa-sha256; cv=none; b=k/TUOifEGLAw+Fcma7CsxQzE/pbV9s21uBTlvEvYRf9NmbSXgXyq+h1Lir4WgfNyp4+eEO VOH2ocnP8A+sU83Fp31Gce4ot+VZGBR2+6CTDdpCfq+kLRqAKgd3b34XK21epcwjCu0Ru4 pGALixhghRv+KopFw2e2JURWP/jV0Ig= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=et6Z88qK; spf=pass (imf29.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.167.177 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692174937; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=wEdYgrJyQcwssjv302WhniVvwDe0CeIVGQ4feBQhaZY=; b=o1fqMm6A6pZJIAdZ3cdYLL0fOknysS9zsgoQFv0L3r7JMlF70c1XY+Rw3oT2FSXdd0oUsS ZmpWD5c3rxotsUjX5Ck0wdXFO9dII/fnP7l1ns69OuY2rbRgkL5J09QELgstAiNcg9RfTB 8wxElclhu6EyiLg8d+1NbbEq+YFFfLA= Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3a739c3086cso724891b6e.1 for ; Wed, 16 Aug 2023 01:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1692174936; x=1692779736; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wEdYgrJyQcwssjv302WhniVvwDe0CeIVGQ4feBQhaZY=; b=et6Z88qKe8udA5UmW5oLmTpORkL3fIeyIwXvJu5IDozzfA5uufancc+rrBd0ryt6JC 6B+J4OmPEbPTFRuR9eKr6ReSS8A4rZiqou2GXvBTPACQyHw1ViltTTNm0wDEVNssyZtm 30sJNa/9x+0axRmKkdDF7edtwJSdqKpCcory28n4elEgjjuHTF34l/gDYGL2D31U0C8D i8UmplinKNtMrFYDe8xbzWWloasxtiXFLe2jOACr3e0IqmCMVRJod1OIWmZwb294Idmp b3W/BFdU/Fvw2X6rlj7kFmRwm7hqhNoAW5QKRgmFZOFXovnnMf3t1uqssqOhPGxF/+2V JsAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692174936; x=1692779736; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wEdYgrJyQcwssjv302WhniVvwDe0CeIVGQ4feBQhaZY=; b=VdeKP+XJHVigOZJQcHwlErMFscxUluElfmhJaaHqxoPzzBn0m3tYBSeoYS1DW64sXP dc2W3t1VfdzhqBcjpc65oD0MpXcYGA9C8PQTYq/1T8ABS6rDmRG7qceVGxmv1MiFtTsZ vDJwTuH20S7FyQjHjBSXg0vBJA9fmTfb6OykjQIiXy7NXhBcoMBTOqQ0GPxYRdVrtlDy bBh8K58CzhLxx/+fVoDggL7sm3vj88AhuGzjH82qE7++oZ00Eco50OM3pEj0cRqO8TXR GdH1MNa/5fm/H1o84JveU4LFB5JjUz6s1W5NbfY7cQXF0XAPH00xCY6zUrTACIk4NeTN esAA== X-Gm-Message-State: AOJu0YzEP8Jiq9KAivXtXEAnWa3t6NNLpIf6MBo9gRrQJPn2Q/o5z3tA xJ0sBWxhj7+E1YHo9GqvBtP/EA== X-Google-Smtp-Source: AGHT+IFaewitmFjxr4BvO1FUDyDefEj0UVoHIPf+uKAL+8+YoBigpvW7yp/jXIUbm7qypbdXYQDY6g== X-Received: by 2002:a05:6808:3a19:b0:3a8:175f:86de with SMTP id gr25-20020a0568083a1900b003a8175f86demr1196396oib.5.1692174935973; Wed, 16 Aug 2023 01:35:35 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id p16-20020a639510000000b005658d3a46d7sm7506333pgd.84.2023.08.16.01.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 01:35:35 -0700 (PDT) From: Qi Zheng To: akpm@linux-foundation.org, david@fromorbit.com, tkhai@ya.ru, vbabka@suse.cz, roman.gushchin@linux.dev, djwong@kernel.org, brauner@kernel.org, paulmck@kernel.org, tytso@mit.edu, steven.price@arm.com, cel@kernel.org, senozhatsky@chromium.org, yujie.liu@intel.com, gregkh@linuxfoundation.org, muchun.song@linux.dev, joel@joelfernandes.org, christian.koenig@amd.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, Qi Zheng Subject: [PATCH 0/5] use refcount+RCU method to implement lockless slab shrink (part 1) Date: Wed, 16 Aug 2023 16:34:14 +0800 Message-Id: <20230816083419.41088-1-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 316BD120004 X-Stat-Signature: ufawbr76kr3ifmmxsxkziewi7k3iu35n X-Rspam-User: X-HE-Tag: 1692174936-204282 X-HE-Meta: U2FsdGVkX19QLebaAJqOKZ7A3U/DJBPiw9qPbqcXd2g23Ak8KXt/hjCHBGpp07hq11V81frliu7FA3r+Zcg8niDRYuE/IFnRD/D3S78RC0hANTdTkWySoYLtezC19zDrHfnbxEpalXfrX0H64u2hXB/8xtY8cs7wYrOSIOXe8WsdCnJGVN3dtM4Lg713hvj+W1MStQ4ellO0n08/NuUfAGEbt9iIC1hF0teEQGYK14zc3qG3Gg2Ja7/JSCVC5LYcXScXm0/+K2POk090f+i1FJ50TPK2S3rAWItlKu3bSSAALjl36n4QgkQ3hVPQb3An8Kuv9KvBwxb2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8+SuQM4tMxq+aQmrWDV3fgWRxY33VqAm27RH6YVDFGOUgHYtqI1SIOqud 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: Hi all, To make reviewing and updating easier, I've chosen to split the previous patchset[1] into the following three parts: part 1: some cleanups and preparations part 2: introduce new APIs and convert all shrinnkers to use these part 3: implement lockless slab shrink This series is the part 1. Comments and suggestions are welcome. [1]. https://lore.kernel.org/lkml/20230807110936.21819-1-zhengqi.arch@bytedance.com/ Thanks, Qi Changlog in v4 -> part 1 v1: - split from the previous large patchset - fix comment format in [PATCH v4 01/48] (pointed by Muchun Song) - change to use kzalloc_node() and fix typo in [PATCH v4 44/48] (pointed by Dave Chinner) - collect Reviewed-bys - rebase onto the next-20230815 Qi Zheng (5): mm: move some shrinker-related function declarations to mm/internal.h mm: vmscan: move shrinker-related code into a separate file mm: shrinker: remove redundant shrinker_rwsem in debugfs operations drm/ttm: introduce pool_shrink_rwsem mm: shrinker: add a secondary array for shrinker_info::{map, nr_deferred} drivers/gpu/drm/ttm/ttm_pool.c | 15 + include/linux/memcontrol.h | 12 +- include/linux/shrinker.h | 37 +- mm/Makefile | 4 +- mm/internal.h | 28 ++ mm/shrinker.c | 751 +++++++++++++++++++++++++++++++++ mm/shrinker_debug.c | 16 +- mm/vmscan.c | 701 ------------------------------ 8 files changed, 815 insertions(+), 749 deletions(-) create mode 100644 mm/shrinker.c