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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CB42C433FE for ; Mon, 27 Sep 2021 12:16:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0139861074 for ; Mon, 27 Sep 2021 12:16:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0139861074 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 4AD57900002; Mon, 27 Sep 2021 08:16:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45C366B0072; Mon, 27 Sep 2021 08:16:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34E3E900002; Mon, 27 Sep 2021 08:16:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0186.hostedemail.com [216.40.44.186]) by kanga.kvack.org (Postfix) with ESMTP id 2366A6B0071 for ; Mon, 27 Sep 2021 08:16:15 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CF76A8249980 for ; Mon, 27 Sep 2021 12:16:14 +0000 (UTC) X-FDA: 78633250668.19.77AA414 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf10.hostedemail.com (Postfix) with ESMTP id 82A1C6001982 for ; Mon, 27 Sep 2021 12:16:14 +0000 (UTC) Received: from relay1.suse.de (relay1.suse.de [149.44.160.133]) by smtp-out2.suse.de (Postfix) with ESMTP id 30DEA200E7; Mon, 27 Sep 2021 12:16:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1632744973; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2JDyFY0B3V9u0p2eeZcWAu9t3CijjbBnbN1ws98VWnc=; b=gjmUPk3C5xGi5oim5i9/JuTCCSv6JcT1ecg0vJtcmB+J8Og9bG/A2m7LIp3X5sBEr2OUWJ NLH5mhxkp0X4oSVSxmRvW6I7LLkBJyYLSf09WH6YkMkLI7cy/UUqw0BIHBLaRKAectrMTH lgGT7DTUWirra+wKWcFlP+x0QXY1JEc= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay1.suse.de (Postfix) with ESMTPS id A22EA25D3C; Mon, 27 Sep 2021 12:16:12 +0000 (UTC) Date: Mon, 27 Sep 2021 14:16:12 +0200 From: Michal Hocko To: Nadav Amit Cc: David Hildenbrand , Andrew Morton , Linux-MM , Linux Kernel Mailing List , Peter Xu , Andrea Arcangeli , Minchan Kim , Colin Cross , Suren Baghdasarya , Mike Rapoport Subject: Re: [RFC PATCH 0/8] mm/madvise: support process_madvise(MADV_DONTNEED) Message-ID: References: <20210926161259.238054-1-namit@vmware.com> <7ce823c8-cfbf-cc59-9fc7-9aa3a79740c3@redhat.com> <6E8A03DD-175F-4A21-BCD7-383D61344521@gmail.com> <2753a311-4d5f-8bc5-ce6f-10063e3c6167@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=gjmUPk3C; spf=pass (imf10.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 82A1C6001982 X-Stat-Signature: tzx4i1znkwjha5hcxcram5mz31szpi8c X-HE-Tag: 1632744974-448475 Content-Transfer-Encoding: quoted-printable 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 Mon 27-09-21 05:00:11, Nadav Amit wrote: [...] > The manager is notified on memory regions that it should monitor > (through PTRACE/LD_PRELOAD/explicit-API). It then monitors these region= s > using the remote-userfaultfd that you saw on the second thread. When it= wants > to reclaim (anonymous) memory, it: >=20 > 1. Uses UFFD-WP to protect that memory (and for this matter I got a vec= tored > UFFD-WP to do so efficiently, a patch which I did not send yet). > 2. Calls process_vm_readv() to read that memory of that process. > 3. Write it back to =E2=80=9Cswap=E2=80=9D. > 4. Calls process_madvise(MADV_DONTNEED) to zap it. Why cannot you use MADV_PAGEOUT/MADV_COLD for this usecase? MADV_DONTNEED on a remote process has been proposed in the past several times and it has always been rejected because it is a free ticket to all sorts of hard to debug problems as it is just a free ticket for a remote memory corruption. An additional capability requirement might reduce the risk to some degree but I still do not think this is a good idea. --=20 Michal Hocko SUSE Labs