Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3899884pxb; Mon, 27 Sep 2021 05:17:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6JYBfb2e3oDttMqGiktydQsJZNehhtDwqYwu3vtxH+ikzL/kmdujgqym/ke1aQiuy3sG1 X-Received: by 2002:a17:90b:4f88:: with SMTP id qe8mr19972982pjb.22.1632745064531; Mon, 27 Sep 2021 05:17:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632745064; cv=none; d=google.com; s=arc-20160816; b=pJm3clnHHCMbP5FGTHgRByA0DESay2QpI7A6w9JHDTEWgZQ8rVL/nETCgQV559tyoY ax9Q6bCigri6qNsGDKmcYVOgjZSqCDvzlIFiygLht06NuPmMolxXH7sMk8EVNdvRqaUn vZuXVFIVb2jzpifwIHO/DfOaQNjoHuie7zq1tq+0ZPUmA2k4O+4rVaA5N0p6BPeWSuBY aZysjrz08MlAMTsrZ77cRg98evq+e5CyJEMzuNSV0VAqPK7pIarecmPVtj5Uc/NMMXX1 3Fx0g5fvPhRsFBCHITmRRnWr7Ikm8bxnUban1OzlX88NMyuUFXDoo+uW7hsJGrPFI97q WqSA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2JDyFY0B3V9u0p2eeZcWAu9t3CijjbBnbN1ws98VWnc=; b=auJGZ83xeqe8TvfgHZYwKQKnSQznob9PGVv1wyu89wDbvVI1JUYUiOWokIPrhC+JSn askQgbFftn1BhxpJsCrcILwDxvmyVNon71gMWZRvc1JgvHOFbcbDbIlKdLlGhhejxxWg MCG4fj8SeXyR/0Kcubxxe1XrfESrVuHeWFQdG3hqL/C1zg/3PRaTLgiQgsGMhjZznXis +EXGYRsLo2C6OTQNW25GyMopn0mJFhoViQvQ3TUFPQHltFajhMJlRTLz5DZNMPW6VQbr XX76Tw76UyjkioGQoTkKeX9Wls9JaEw1LfJd6Tn6gNFOanjjfS33QqX+EIH81QUgfdlA 8pRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=gjmUPk3C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m15si23382975plx.14.2021.09.27.05.17.30; Mon, 27 Sep 2021 05:17:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=gjmUPk3C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234317AbhI0MSS (ORCPT + 99 others); Mon, 27 Sep 2021 08:18:18 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:48216 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234280AbhI0MRz (ORCPT ); Mon, 27 Sep 2021 08:17:55 -0400 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 Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 regions > using the remote-userfaultfd that you saw on the second thread. When it wants > to reclaim (anonymous) memory, it: > > 1. Uses UFFD-WP to protect that memory (and for this matter I got a vectored > 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 “swap”. > 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. -- Michal Hocko SUSE Labs