Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp236454iob; Wed, 18 May 2022 00:43:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkl66kjVzKBX53QrjkY9Eo/ii+g/SPajFNXq5kybFXd1pOO209hxKc8pmsrWmEPt1rve71 X-Received: by 2002:a63:cd01:0:b0:3f2:7f8d:14e8 with SMTP id i1-20020a63cd01000000b003f27f8d14e8mr9512537pgg.491.1652859825686; Wed, 18 May 2022 00:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652859825; cv=none; d=google.com; s=arc-20160816; b=EQvvbJ3NeS7euvQioGWGHB/8DMiIzqdIaS1bSUBfTHG94kMPoz2TUUb/F3OKOvFJxH ByTAK553lZ99ruFBEaIluQT9voQ8k3HQiGzTN8sXL+4K54gufhOm1/vo7r2hcOc3apaw yn+riiACHvWjvnV4CnGLk1DtyviHm0olI+NJOqfubXwyJkkK0A6U9vN6o6NhsJ8WgX+z GAxAWqn8NK5jeX97pJjVEWtBfCcvwQSMz95vUBANrm43eN2JBmWqZJbaBv+ERFKyzYym 2Xew1zTzYOA1Dmc9DvURHzQUYU/O6sfFOGAWgdJjYsybIJmykkA0TfxGr3OxV8ks8M9Y lI2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:subject:cc:to:from:date:message-id:dkim-signature; bh=FxAwdbb/Z2iFz9mmHnLiOpxEpn9tLUeGCl2bRMYRR98=; b=ykox4RDRadMTtnKKt0EfzuHeSlObNubzw7gcsCoyKGP1jwPbb1TuHE+2rLAW7EneLV 2Mu4MC6GyAsBcmE3eqAmbIG/HP/aSZVVb+BMDn/71WMXcNvA+7eNvoZ2q6RrdoMmdKGT bX8SUZAqwyJGGUAQzKK3r3peAZHKb1E4QeTH6CQY2HcLr8PjoZn/r+Qr0yV2G0T/xkzy puHfKDVDtLhsFQrTi9pWEyIEagc2PVIzbeX35G1dit43GsagNaYSawaoVbM14pBQpQGc Dgoz5UuB3jepNaDXDAqYrGUDxGdCURmMmP9YY9F6TKv3kd3783RJW2dOHQ113C4l1rif XYiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="coF2p/xt"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s123-20020a637781000000b003f5f02cfd37si1637314pgc.466.2022.05.18.00.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 00:43:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="coF2p/xt"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 28ED4262F; Wed, 18 May 2022 00:40:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232243AbiERHkm (ORCPT + 99 others); Wed, 18 May 2022 03:40:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232262AbiERHkg (ORCPT ); Wed, 18 May 2022 03:40:36 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA566118024 for ; Wed, 18 May 2022 00:40:32 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id gg20so1235245pjb.1 for ; Wed, 18 May 2022 00:40:32 -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=lzuYluG2kkenmSuLh+U2/YRAL5ek8SXvCh2T1U85PIeTvwZF3N90jBriBzG0tdzD0e em85M5jNhGEwH08NdCeqMwOPkGvMSrxmCtA0q1ahKWz49K7lPE20VB22CKdPHJ2MJ8+G FSj4GFENIo3H/Jm/83plQNGm7zSi5WGuIlZGbgIsASU2uOysOoTvdP6TF2gQEHXIOa72 B7v9feUD2Q08Owkjp9mU+WLL44p8wB/fxYIo/tUPXjBkXmbp4NL/IC2vomR4sh9hg+tb VDPW8fsD9IHnSEisq8Cr/vpw7FQJETOHJK7VqK1KBu5wJ4V+rvWCp/W34ZG+gvnEn9Jm L4UQ== X-Gm-Message-State: AOAM533h38aRzg/c179DfQ54bD4FvBFn0VMLrrEvsiYH4yZKx8y0E45S GrmzqsIJKbAniIJ43h5xeLw= 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-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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