Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1046268iob; Fri, 13 May 2022 20:58:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQqqll3uGFj3vnfqcLq4Mg+6oY7o5WbDG+l6PeSGOnfRVQHQpMIUOgD8p0O+fOj5s190HE X-Received: by 2002:adf:e646:0:b0:20a:c4fa:4991 with SMTP id b6-20020adfe646000000b0020ac4fa4991mr6040616wrn.413.1652500687889; Fri, 13 May 2022 20:58:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652500687; cv=none; d=google.com; s=arc-20160816; b=tp35L5I2UgQYppVIJ6Apaa5SCq/nPFgRGuGPhzxs6tgspZvnbthnFcZL/2L/6GOUCi V1dyTM6R0tS4ltzifwjbIv0KlvrywMCWGG77f3pa1aok9eYOS9IvnK34NIFvB0mHEqTg j9M/s3V8OZ40yUm1QXgNsB5q0lBR/Qm/FF/Zz4Nt5+dqy7TKiRoC6VWbX/Hspq+hAF0n LKzrx7FtuQfk/6J9LbgUp8tb88frLrA7y+hAFJqVhnIydK3rgNqJswzTOi2HugGwfWoo C2ghHuxp6e1ud8mCNpwQfraGINZJSGIeNU6B3EJigvFJeiP2vytZVHeFdWCMab0Uu9Vg jWJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=FtTkLpM5T/c22OlUTVx5dgAZ6KpaqNAYpR/LwdhFglg=; b=m4RbH07AU1MRlr+jCHEHueSHwd3kIQZ97pD50f8A8At+5gH7luEaVf6x098oUzdF7m C+XAqJgloJQK0xATnjpLxY9wkxp1kn0ZuU9AfqqkhrCmxCAWdD5fUg506030dezDM4IY diERfe67xdifh6nPehNjXL0zhDSkgHi/1rEBpa6YEyj2MbGHZmWcoZvqWAdjq3KXun45 j+eLZACpe+raOiI1VvW8afWGaOBLpTVTDZ1eU+KItQbPIpstn1geT+jB5vOyJfG4bMC3 IW7Hx4qroehHdyLol2trIuUsW1DO+FRu5rafk4Ca54GMQkliFZ7DExkW4j0vlCOQtZx7 YVvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=PMBURyUl; 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 Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t6-20020a1c4606000000b0039450db8743si7462266wma.200.2022.05.13.20.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:58:07 -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=@linux-foundation.org header.s=korg header.b=PMBURyUl; 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1BD9F49783C; Fri, 13 May 2022 17:29:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359231AbiELWh7 (ORCPT + 99 others); Thu, 12 May 2022 18:37:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359204AbiELWh6 (ORCPT ); Thu, 12 May 2022 18:37:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E007F261943; Thu, 12 May 2022 15:37:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AAC00B82910; Thu, 12 May 2022 22:37:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 049ACC385B8; Thu, 12 May 2022 22:37:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1652395074; bh=iXYbrakwOy8fAS30CpfPw/fAsO6kge5ixveO1uxKU/I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=PMBURyUly2UezZiNvUykZHn33IlAWIMcuk7bTxPjWZyZ3Ag10LKIXURsFE3JF4NJx SYgAhZDbYdpgl394L62xDISq1OGnn8EsEJqmcO3utNvrphDGTsPxMz/vc6xBZydBrT YORPRsmlAVMS5yX+P3jHKm16rK21uDwj7kqO7/IU= Date: Thu, 12 May 2022 15:37:53 -0700 From: Andrew Morton To: Oleksandr Natalenko Cc: cgel.zte@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, corbet@lwn.net, xu xin , Yang Yang , Ran Xiaokai , wangyong , Yunkai Zhang , Matthew Wilcox Subject: Re: [PATCH v6] mm/ksm: introduce ksm_force for each process Message-Id: <20220512153753.6f999fa8f5519753d43b8fd5@linux-foundation.org> In-Reply-To: <5820954.lOV4Wx5bFT@natalenko.name> References: <20220510122242.1380536-1-xu.xin16@zte.com.cn> <5820954.lOV4Wx5bFT@natalenko.name> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Tue, 10 May 2022 15:30:36 +0200 Oleksandr Natalenko wrote: > > If ksm_force is set to 1, force all anonymous and 'qualified' VMAs > > of this mm to be involved in KSM scanning without explicitly calling > > madvise to mark VMA as MADV_MERGEABLE. But It is effective only when > > the klob of /sys/kernel/mm/ksm/run is set as 1. > > > > If ksm_force is set to 0, cancel the feature of ksm_force of this > > process (fallback to the default state) and unmerge those merged pages > > belonging to VMAs which is not madvised as MADV_MERGEABLE of this process, > > but still leave MADV_MERGEABLE areas merged. > > To my best knowledge, last time a forcible KSM was discussed (see threads [1], [2], [3] and probably others) it was concluded that a) procfs was a horrible interface for things like this one; and b) process_madvise() syscall was among the best suggested places to implement this (which would require a more tricky handling from userspace, but still). > > So, what changed since that discussion? > > P.S. For now I do it via dedicated syscall, but I'm not trying to upstream this approach. Why are you patching the kernel with a new syscall rather than using process_madvise()?