From mboxrd@z Thu Jan 1 00:00:00 1970 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 DCAADE7E64B for ; Tue, 26 Sep 2023 16:16:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 413098D0035; Tue, 26 Sep 2023 12:16:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 39C3E8D0002; Tue, 26 Sep 2023 12:16:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 215F08D0035; Tue, 26 Sep 2023 12:16:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0F6EE8D0002 for ; Tue, 26 Sep 2023 12:16:39 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DA7F1B3E99 for ; Tue, 26 Sep 2023 16:16:38 +0000 (UTC) X-FDA: 81279251676.23.400D0F1 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by imf15.hostedemail.com (Postfix) with ESMTP id B6181A0040 for ; Tue, 26 Sep 2023 16:16:36 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=devkernel.io header.s=fm3 header.b=Zg64SfB5; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=dckkDotC; spf=pass (imf15.hostedemail.com: domain of shr@devkernel.io designates 66.111.4.27 as permitted sender) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695744996; a=rsa-sha256; cv=none; b=l2npLpM7rRzhCD1rMJro4zjfAPyjL0U3m0MsMK30vFWwhvyJAd2wHM08ltgerPismbD1au 9uOD+Y06ymWO/fjx2H/34NyPqPqXl/dY4MoDbpRDtqrSEx45hIsHzoGrt6LjyL9STmfIdT TeyLDMNdx4JMK450hJjTvO7h3ts3+GM= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=devkernel.io header.s=fm3 header.b=Zg64SfB5; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=dckkDotC; spf=pass (imf15.hostedemail.com: domain of shr@devkernel.io designates 66.111.4.27 as permitted sender) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695744996; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=I8dC3DP9zi7HuNHGX4/XDLMbigK9k3MpPIy6l2HTeZE=; b=h5U5iX/7hkj5rjtC9OXhI7uca0MVrJopiY1lbliJkgJF6Vy8tfgctZWGg62Cec9f0gKEvd iQmHUsxRzqNdXnDsOyit5UWQ7X4Ke53pW29jHtdbbtOgdc0knpyQGRTnoLRkFMXt/5/nIi aCy7J8CItYAk20FX2yknbtTC3QnhoT8= Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E66865C00A0; Tue, 26 Sep 2023 12:16:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 26 Sep 2023 12:16:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devkernel.io; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1695744995; x=1695831395; bh=I8 dC3DP9zi7HuNHGX4/XDLMbigK9k3MpPIy6l2HTeZE=; b=Zg64SfB59AcBYJQ+H7 QaKBUJk1pe6142rAvTPPskcVLvsCFSZg/GGZ3Oml6Bk35quwVSpLNUzbD1n7yVY+ NDJTA6x04X6feFde2q9IMG0RQ5rLq+kfj9W32hCxgX4BCYNhcObFrIDgQwK2Lh+/ /QnksATVwncxOg9AZ5dVfY5v1wCrd7EQGhPC1O/UYDHmlsJpn7qVP99MBhhYiAY5 smDnTC7ZR+dDtFHZbmN8xy+eATvdaou/MGwmJf3skjtb/FLVFjnLX2jPRy8Pgh1F sGLEm3PRbWHVGbZoPveSFuLQyqCJ6Ej71xHeUyZZ7V0ldZHdGh3KrjKKkgOuptIo cjFg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1695744995; x=1695831395; bh=I8dC3DP9zi7Hu NHGX4/XDLMbigK9k3MpPIy6l2HTeZE=; b=dckkDotCK9fhF/+mLZr/VmbmZaKqR dFDBYVmdHPN0pDTLj0hp12hEbq6ORFUYWAPGiQv361v2+yFpS83PFCJvh9y4p+sX 7L4JSQ6L5NKFwUFtTIDA4XdNLnUpsX4L2RRpoE0C1uDGMpJdhuWuO88N0NwrUXhp qIcmy/0QEdy1hjV2Xuv/fHgkZzsy+EZuYmpcM+m2fsTZgzpW+iibdwv0+hYnti1N /yB96iHeVyQTtbay/sBGzI3GgMo4mbF9f9VPXNRBKL4duCM2iOZEZehiPNH2C0EH bTf0/sHU1o+jhLYnwgWIWNEmbJN7NRpbtOE+zxCMTMZgPaC3roRoJAORA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvjedrtddtgdeilecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpehffgfhvfevufffjgfkgggtsehttdertddtredtnecuhfhrohhmpefuthgvfhgr nhcutfhovghstghhuceoshhhrhesuggvvhhkvghrnhgvlhdrihhoqeenucggtffrrghtth gvrhhnpeevlefggffhheduiedtheejveehtdfhtedvhfeludetvdegieekgeeggfdugeeu tdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehshh hrseguvghvkhgvrhhnvghlrdhioh X-ME-Proxy: Feedback-ID: i84614614:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 26 Sep 2023 12:16:34 -0400 (EDT) References: <20230926040939.516161-1-shr@devkernel.io> <20230926040939.516161-2-shr@devkernel.io> User-agent: mu4e 1.10.1; emacs 28.2.50 From: Stefan Roesch To: David Hildenbrand Cc: kernel-team@fb.com, akpm@linux-foundation.org, hannes@cmpxchg.org, riel@surriel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v3 1/4] mm/ksm: add "smart" page scanning mode Date: Tue, 26 Sep 2023 09:13:31 -0700 In-reply-to: Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: B6181A0040 X-Stat-Signature: 75x59oeg4cgt17yn9rodstjaak6pfpwz X-Rspam-User: X-HE-Tag: 1695744996-45560 X-HE-Meta: U2FsdGVkX1/VtSk7gXN1GVQT5vFNqI3qqeODrhwkEwKzLG2QdgAvNpC2BD1yPSHx1TWSTS0E57noEQR+dWrqNGvLeVHZMsQJiEbAWzsWNdkb9qDKUO4MU9zx2CSJsCzJOrIPhHn/8e2D3/QRJF/933HoFVXLhR/HUvOyKog6vy6UHLuG5B/E0SZIfmOvl+p1kDGceTxx8ZINaHDMkmgnLU+iToV7DAzt9UshOK95a14TrqdPaeRFbvQPedoPJkOLq6NPbEwSGvjhnISzHkNrB6Ep2EX1TMWdvCuutarx61p0BY2yA4DNZNGo9OJ1Ewi+EntBSc1Hda0E2GyG711H+4DHeDxZBxG/Vo0i//udd1UacLVCighg4RHtdE3HC5RWvFkF3LDbFKeXiT17IzbzbhFT+y4Hdza0sQ66HwDEt5iCrmPDvqyx7HXoRA/Ec52qHfOLIF/set68xCfp0PISTx4j8yv4yXYVGSzg6Ae0XUp0q984Di6bp3+uvtQJ1mgMSm2AiTPx7lkdE+snTT6lE4eFfGsgBXpfxSBreIU3Dwx95JwELC3KzOLOE1qXUW9jamumI/5tztcGmQqdCMD0A1cHw1hOZTGHKPlACzUs/9iTybzuLI4s0uOvjilnIZ1hCy28neP1rfEauFMQh5PzvMwKvH4klhMVKiX5Ai+Ne2rlLxhw6OVeoluxX4HmaYYyWeIKpxExxwL4fgbVm/4bR/n4kdncrQSpwXhPc8tzKBV7XKvP9VxECYp12pmYKalbi9jQwc2hzDAQGPc4HQdL9BXLHd2TUMte6BgFp7sMchyjwDLdQ1DvAudE0uCg0AatkxhBTRyW88X/80RHqTGC7OsnDNWyykq2+gSQkvxuTrwxLUbmI6VmTYVNpXz/ZV9B/BGhq1FVXJYS9e2BPwm56NQKR7JSV7Lam3ajTKoJKxLrUiKkkoPWIOVnxfgMoM8ezjTtbvXcnmgYKkDByt/ WJdUXwPN 71SINLWcvAwHZywPF+Mm+k/YKevFONcbx0r8YnKKWXw898mBWjzHc7Wb7K5BI3o0ykPuxpiyE5bhrv2nrSsDDz5ceOuhM0Rbe12q9fU6Qzn7/Rk/ZBr5gb9AWuxZxn1Y6YZHqxHWgwr9qeDyy9VPSsJGZD8isZvC1sRSNN7fakkVaAglVeLGUg+mXWZmIAVFMxwUy 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: David Hildenbrand writes: > On 26.09.23 06:09, Stefan Roesch wrote: >> This change adds a "smart" page scanning mode for KSM. So far all the >> candidate pages are continuously scanned to find candidates for >> de-duplication. There are a considerably number of pages that cannot be >> de-duplicated. This is costly in terms of CPU. By using smart scanning >> considerable CPU savings can be achieved. >> This change takes the history of scanning pages into account and skips >> the page scanning of certain pages for a while if de-deduplication for >> this page has not been successful in the past. >> To do this it introduces two new fields in the ksm_rmap_item structure: >> age and remaining_skips. age, is the KSM age and remaining_skips >> determines how often scanning of this page is skipped. The age field is >> incremented each time the page is scanned and the page cannot be de- >> duplicated. age updated is capped at U8_MAX. >> How often a page is skipped is dependent how often de-duplication has >> been tried so far and the number of skips is currently limited to 8. >> This value has shown to be effective with different workloads. >> The feature is currently disable by default and can be enabled with the >> new smart_scan knob. >> The feature has shown to be very effective: upt to 25% of the page scans >> can be eliminated; the pages_to_scan rate can be reduced by 40 - 50% and >> a similar de-duplication rate can be maintained. > > Thinking about it, what are the cons of just enabling this always and not > exposing new toggles? Alternatively, we could make this a compile-time option. > > In general, LGTM, just curious if we really have to make this configurable. > The only downside I can see is that it might take a longer time for some pages to be de-duplicated (a new candidate page is added, but its duplicate is skipped in this round). So it will take longer to de-duplicate this page. I tested with more than one workload, but it might be useful to get some data with additional workloads. I was thinking of enabling it after one or two releases.