From patchwork Wed Aug 31 03:19:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 12960291 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 A2855ECAAA1 for ; Wed, 31 Aug 2022 03:20:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A1BC6B0071; Tue, 30 Aug 2022 23:20:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 02A396B0072; Tue, 30 Aug 2022 23:20:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0CB98D0001; Tue, 30 Aug 2022 23:20:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CAC0E6B0071 for ; Tue, 30 Aug 2022 23:20:10 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9F39380C3F for ; Wed, 31 Aug 2022 03:20:10 +0000 (UTC) X-FDA: 79858434180.19.6A9DACB Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf26.hostedemail.com (Postfix) with ESMTP id 7878D14003D for ; Wed, 31 Aug 2022 03:20:09 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id b196so2705044pga.7 for ; Tue, 30 Aug 2022 20:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=v7Q+HHnOQCPwmVlfrZr6AImldFLltmX8PsInykk2xfI=; b=U65jboiY95Cmqy2YaTAbsIibfhChRdktNV1Du22CPObuhxwOnA8eyc1SxFlUMa5kWG GNMayYyOHqpYZ92tPKgGQnPJJT2yDPjgEmK0MC2U6SJxlA7rvM93Bz4H4JWiYIKwX8DP Hc0AFB3MrtvutmvE3wBnNpxI0V9C7gaL+x/A/bqc+IudJigVLqGOOO/RSwLU89dvdpcr vkxMuMBgHZ+gtCPYWJ75zBPfJV6gW0tjplLBOGQ//toIStK2aWYpTbvOL4/mWdnhCi9n 6zgw/rFvswBkTxEIfRrF5N/tyZjynT91saOsslEnNX+3QTxwFW7mHlHBOA7ICxG4H/JV tdEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=v7Q+HHnOQCPwmVlfrZr6AImldFLltmX8PsInykk2xfI=; b=0QH7NGt1C62cihCrpGzk3LdgvsyBeqdMIz+lGv09hOMRgTx7A3yTGuBnCH3Q47Te1y 0MQ7md/pU86tmQmIpfzoeuY6GN8Zw3CFa9HVwiDxQO9PedMe8xoBU70Sbf+hzhBfj0Oq DJZj56ttLoxfsiHEONrYM9YiDPJSbTEhW9V/dyfCJpq2Jbe0G2TMq6skwLv5kCPDXxlB ykUlBrrOsyqxdLelq2dGc9DIaWQRLbGDNPt9k4xCLcOmmbAdku4h0TrBtXyUC6NXA01k 90jmnvOziamSbkhNtW9nI0cX+qWZ3lbdnK1Kpz0AZUEY+fl/3b8cp6WuTDGirZC8KHjC QhvQ== X-Gm-Message-State: ACgBeo1IpKhUjtSVT2nlyYgacXwqybpE5ETOc8uc0HvSuDdbZHjrXM75 LXDeSscIR+i3FqMHlHWIpXRqUw== X-Google-Smtp-Source: AA6agR7e935S+GyysaLfzhD2W1iEFkDAPWWkN74h5pwx87iu5LAlQQ/LsctQuqZ2LVy/sicAR/Unbg== X-Received: by 2002:aa7:8393:0:b0:537:701d:e7f3 with SMTP id u19-20020aa78393000000b00537701de7f3mr24416745pfm.50.1661916008151; Tue, 30 Aug 2022 20:20:08 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id i13-20020a170902c94d00b0015e8d4eb1d5sm8633535pla.31.2022.08.30.20.20.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 20:20:07 -0700 (PDT) From: Qi Zheng To: akpm@linux-foundation.org, shy828301@gmail.com, willy@infradead.org, vbabka@suse.cz, hannes@cmpxchg.org, minchan@kernel.org, rppt@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng Subject: [PATCH v2 0/7] add common struct mm_slot and use it in THP and KSM Date: Wed, 31 Aug 2022 11:19:44 +0800 Message-Id: <20220831031951.43152-1-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661916010; a=rsa-sha256; cv=none; b=7FGX9LxN9PsC3FLaSSy5Bb/DtmBcpnU89jEGEpLE3TVDPDeGU2RPty9cRgCWEWCcm9CmS3 ZgMdDo/e930FxhkEMBLXrh3ezikYHfrS0/fBX2Cem20hmKINVczY7oo1+/BnPRKU4a/1lu ZMsdFqDPSxsBMhavY9itMLlhivgtJco= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=U65jboiY; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf26.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661916010; 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=v7Q+HHnOQCPwmVlfrZr6AImldFLltmX8PsInykk2xfI=; b=8ZuCYEkPSCtlPgfmy3B86DW4YrM/gTzkw4BsEqoXxwNRH64SiLXN+x+9sv16/wi8KPrvlh xTq2+zv5VQ9s7kAGlLcix18xoPxurNFKgSBQ5T1Ge4jIh4Kfimb6uBPDFDTFeWoPmDkMXy rzTZKjzWcqiQL3KJoLenW/N1xdtM1EY= Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=U65jboiY; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf26.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: 3oywd8dmayixzk5888qfj9rpeq6m3gr5 X-Rspamd-Queue-Id: 7878D14003D X-HE-Tag: 1661916009-259249 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, At present, both THP and KSM module have similar structures mm_slot for organizing and recording the information required for scanning mm, and each defines the following exactly the same operation functions: - alloc_mm_slot - free_mm_slot - get_mm_slot - insert_to_mm_slots_hash In order to de-duplicate these codes, this patchset introduces a common struct mm_slot, and lets THP and KSM to use it. This series is based on next-20220829. Comments and suggestions are welcome. Thanks, Qi. Changelog in v1 -> v2: - change the names of these mm_slot related operation functions (suggested by Andrew) Qi Zheng (7): mm: introduce common struct mm_slot mm: thp: convert to use common struct mm_slot ksm: remove redundant declarations in ksm.h ksm: add the ksm prefix to the names of the ksm private structures ksm: convert ksm_mm_slot.mm_list to ksm_mm_slot.mm_node ksm: convert ksm_mm_slot.link to ksm_mm_slot.hash ksm: convert to use common struct mm_slot Documentation/mm/ksm.rst | 2 +- include/linux/ksm.h | 3 - mm/khugepaged.c | 121 ++++++--------- mm/ksm.c | 326 ++++++++++++++++++--------------------- mm/mm_slot.h | 55 +++++++ 5 files changed, 260 insertions(+), 247 deletions(-) create mode 100644 mm/mm_slot.h