Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6446632yba; Tue, 14 May 2019 07:43:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzWI6yQUcXvBLUC04hKRok2eAZtMFGysTBKfBtcce9MFo58pHKhuw2PgNHiQ0Gzxwi6Htt X-Received: by 2002:a17:902:f208:: with SMTP id gn8mr38619433plb.312.1557845004851; Tue, 14 May 2019 07:43:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557845004; cv=none; d=google.com; s=arc-20160816; b=KxyMXAN8Tagz0avlPWi5O+/0mJ8cXoHdZ9qdTpDgM03IMG9c7/EmZYNZx/IDO05gKd FY7pGL6/QfCAfvotjzIIKDK3iVtTFdOzjuP8DmdxRZdUVTzpx35r1gaC0chxf26DeU1b bK1QN7J4esHOcpHhLiGOP/pRm0ru25WAJ1DxDMVqnG5fcLbAqhSi80wW5rSXxkx1MuoM ySvkx7+luRZrT9GTzljOkXJ3OZccDMV29LdkfeDpAWyHl3r80+CHMn4oUpIbFyW2eaXg E5WKGWgWNfvY9xKgWn96FjJAb/XYY8DH0Wll0TydonXmXcegPRvlkgOAzi+15YiAyc5y tVkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=4pBFWQ4DnvT7PXcFjZRNsJcu+Bsqbpj8f0CIeSOBqkE=; b=KvoGm+q40iAlckBtwxZBFctHMgPrNCgQClKHTQjGNoAGp+KTFhFEPrIcYeilAUXd/Z pAx99BzaFZdP56ev1W9bW6S09MSwj35Ig0cMFQsTi3Ai9B6Mr1rGm/GhFsW4ynWosUM/ Ygyf8LiLCaxtCucPqSA4K9300Iw3Qzn7SrH6OQTPb23dhe0xGtRYJwh8PbWZWJf5csCh C+aqggUevbMWTUwSNoRK6BLaFfFB44ni05xyXj0EEhvi0DgSaXUYPYwewjw15wSOHRm/ 4Ejl2KaxlERK/89nN40zA+zypQjfRj+a/9xarQS8z1zQX6ad4zQQcS70hVJxCabfDQBA 0s7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bh3si19340709plb.284.2019.05.14.07.43.09; Tue, 14 May 2019 07:43:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726487AbfENOlI (ORCPT + 99 others); Tue, 14 May 2019 10:41:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:33148 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726151AbfENOlH (ORCPT ); Tue, 14 May 2019 10:41:07 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 16AAFAC38; Tue, 14 May 2019 14:41:06 +0000 (UTC) Date: Tue, 14 May 2019 16:41:05 +0200 From: Michal Hocko To: Oleksandr Natalenko Cc: linux-kernel@vger.kernel.org, Kirill Tkhai , Vlastimil Babka , Matthew Wilcox , Pavel Tatashin , Timofey Titovets , Aaron Tomlin , Grzegorz Halat , linux-mm@kvack.org, linux-api@vger.kernel.org Subject: Re: [PATCH RFC v2 0/4] mm/ksm: add option to automerge VMAs Message-ID: <20190514144105.GF4683@dhcp22.suse.cz> References: <20190514131654.25463-1-oleksandr@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190514131654.25463-1-oleksandr@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [This is adding a new user visible interface so you should be CCing linux-api mailing list. Also CC Hugh for KSM in general. Done now] On Tue 14-05-19 15:16:50, Oleksandr Natalenko wrote: > By default, KSM works only on memory that is marked by madvise(). And the > only way to get around that is to either: > > * use LD_PRELOAD; or > * patch the kernel with something like UKSM or PKSM. > > Instead, lets implement a sysfs knob, which allows marking VMAs as > mergeable. This can be used manually on some task in question or by some > small userspace helper daemon. > > The knob is named "force_madvise", and it is write-only. It accepts a PID > to act on. To mark the VMAs as mergeable, use: > > # echo PID > /sys/kernel/mm/ksm/force_madvise > > To unmerge all the VMAs, use the same approach, prepending the PID with > the "minus" sign: > > # echo -PID > /sys/kernel/mm/ksm/force_madvise > > This patchset is based on earlier Timofey's submission [1], but it doesn't > use dedicated kthread to walk through the list of tasks/VMAs. Instead, > it is up to userspace to traverse all the tasks in /proc if needed. > > The previous suggestion [2] was based on amending do_anonymous_page() > handler to implement fully automatic mode, but this approach was > incorrect due to improper locking and not desired due to excessive > complexity. > > The current approach just implements minimal interface and leaves the > decision on how and when to act to userspace. Please make sure to describe a usecase that warrants adding a new interface we have to maintain for ever. > > Thanks. > > [1] https://lore.kernel.org/patchwork/patch/1012142/ > [2] http://lkml.iu.edu/hypermail/linux/kernel/1905.1/02417.html > > Oleksandr Natalenko (4): > mm/ksm: introduce ksm_enter() helper > mm/ksm: introduce ksm_leave() helper > mm/ksm: introduce force_madvise knob > mm/ksm: add force merging/unmerging documentation > > Documentation/admin-guide/mm/ksm.rst | 11 ++ > mm/ksm.c | 160 +++++++++++++++++++++------ > 2 files changed, 137 insertions(+), 34 deletions(-) > > -- > 2.21.0 > -- Michal Hocko SUSE Labs