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 965CAC433EF for ; Wed, 18 May 2022 07:40:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 284676B0074; Wed, 18 May 2022 03:40:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 234C88D0001; Wed, 18 May 2022 03:40:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1245F6B0078; Wed, 18 May 2022 03:40:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 025A96B0074 for ; Wed, 18 May 2022 03:40:33 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CBA52307B4 for ; Wed, 18 May 2022 07:40:33 +0000 (UTC) X-FDA: 79478066346.21.7F021A5 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf15.hostedemail.com (Postfix) with ESMTP id 95966A00C9 for ; Wed, 18 May 2022 07:40:17 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id o13-20020a17090a9f8d00b001df3fc52ea7so4823734pjp.3 for ; Wed, 18 May 2022 00:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:from:to:cc:subject:references:mime-version :content-disposition:in-reply-to; bh=FxAwdbb/Z2iFz9mmHnLiOpxEpn9tLUeGCl2bRMYRR98=; b=coF2p/xtqq5kbzcw8z4gzgPU4TNTmE5367fdqBh/2EUUAdcDvu58bgq1CV3Vmduw48 cfYzCRdFI5K+bKAYN4UbYXjXvv5GXUy720PTldYLLT7R3XiFfkDATOmTturvUS1BJgFk Ls2Vi726DI3gyhqczftszBPB1OGh/6synGEc4RYSFwyzvNKtMLJWQOzB21gdEOLsNB1n pRcMQeeVGCoDVonB/ueqn9qhMpEougAaZLTdRiWHCu/R62yvD6mlmPbxoedKjoLlozr9 RZTUmFoNIKE/F3hRjRSrefBDMhgy/gtKI2Luplt216tpNvJeJmKNHgLfd0frchAH2Thv 5r1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:from:to:cc:subject:references :mime-version:content-disposition:in-reply-to; bh=FxAwdbb/Z2iFz9mmHnLiOpxEpn9tLUeGCl2bRMYRR98=; b=Ea+zh1AVvddzGUI9BXJOC3A4iLqTpJsvA9THC5gbNHygSaF1S7LmtqPXBW61KBDCno vYN2YF/szUeJxj005YOBNg4RKcAEBWfK+LWfb0cEFACOMQK2R8BD9IandtrkPIOnLj3V f2U4IFPieNYf3By7GPfdkigiHHTzSf6FY/+TVpYfInkLE8OukevBgQdvgKxqEkRSiHzI tRvSVI42FdxPY+rld23de+2JWiUNmJHHleso+tVFOvSJSB8kS5KkI7H3e526v6P4fVw6 BhK1b/JimRot9iu7GEppu1s7bx+JECu/7q0TM0BSW5sIWcl8VUJ3sFOuMzsTKCEnLXa9 r4gQ== X-Gm-Message-State: AOAM533agvPgezCSQHXFUQIu+Bl6UZzIRRPQaDoJqOuj5hpmVQGqUnlJ EUG1OEdoJBl6cA6d9I2pghU/vxMOrtc= X-Google-Smtp-Source: ABdhPJyuknGHZVYZTShNJtstyABeDVn/mGApt/yIW0GYpaFDALyef+05Id2jETX+j4m/cFJpDMbg4g== X-Received: by 2002:a17:902:7d89:b0:15e:e999:6b88 with SMTP id a9-20020a1709027d8900b0015ee9996b88mr26201726plm.98.1652859632287; Wed, 18 May 2022 00:40:32 -0700 (PDT) Received: from localhost ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id d132-20020a621d8a000000b0050dc76281bcsm1096213pfd.150.2022.05.18.00.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 00:40:31 -0700 (PDT) Message-ID: <6284a2ef.1c69fb81.e53cd.32b2@mx.google.com> X-Google-Original-Message-ID: <20220518074030.GA1686385@cgel.zte@gmail.com> Date: Wed, 18 May 2022 07:40:30 +0000 From: CGEL To: Balbir Singh Cc: akpm@linux-foundation.org, ammarfaizi2@gnuweeb.org, oleksandr@natalenko.name, willy@infradead.org, linux-mm@kvack.org, corbet@lwn.net, linux-kernel@vger.kernel.org, xu xin , Yang Yang , Ran Xiaokai , wangyong , Yunkai Zhang , Jiang Xuexin Subject: Re: [PATCH] mm/ksm: introduce ksm_enabled for each processg References: <20220517092701.1662641-1-xu.xin16@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 95966A00C9 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="coF2p/xt"; spf=pass (imf15.hostedemail.com: domain of cgel.zte@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=cgel.zte@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: n7gd5ipp3ozma8kf6w3817rx8ejs8n75 X-HE-Tag: 1652859617-117825 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: On Wed, May 18, 2022 at 04:58:27PM +1000, Balbir Singh wrote: > On Tue, May 17, 2022 at 09:27:01AM +0000, cgel.zte@gmail.com wrote: > > From: xu xin > > > > For now, if we want to use KSM to merge pages of some apps, we have to > > explicitly call madvise() in application code, which means installed > > apps on OS needs to be uninstall and source code needs to be modified. > > It is very inconvenient because sometimes users or app developers are not > > willing to modify their app source codes for any reasons. > > > > I thought we got process_madvise in 5.13, doesn't that help solve the > problem with extensions to advice and an appropriate wrapper? Granted > it might be a little racy with a running process potentially > participating in KSM already. The reasons why I don't use process_madvise to achieve this include: 1. see https://lore.kernel.org/lkml/1835064.A2aMcgg3dW@natalenko.name/ 2. process_madvise is still a kind of madvise. processs_madvise from another process overrides the intention of origin app code ifself that also calls madvise, which is unrecoverable. For example, if a process "A" which madvises just one part of VMAs (not all) as MERGEABLE run on the OS already, meanwhile, if another process which doesn't know the information of "A" 's MERGEABLE areas, then call process_madvise to advise all VMAs of "A" as MERGEABLE, the original MERGEABLE information of "A" calling madivse is erasured permanently. > If we are concerned about KSM, I would assume that we care about long running processes, is that true? > Yes, it is. > Balbir Singh