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 7947CC433EF for ; Mon, 27 Sep 2021 10:58:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 177C160F3A for ; Mon, 27 Sep 2021 10:58:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 177C160F3A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 48FA06B0071; Mon, 27 Sep 2021 06:58:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43E4C900002; Mon, 27 Sep 2021 06:58:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3058F6B0073; Mon, 27 Sep 2021 06:58:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0240.hostedemail.com [216.40.44.240]) by kanga.kvack.org (Postfix) with ESMTP id 1D9976B0071 for ; Mon, 27 Sep 2021 06:58:57 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D39851802BC96 for ; Mon, 27 Sep 2021 10:58:56 +0000 (UTC) X-FDA: 78633055872.12.01A6880 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 7CC4D801A89F for ; Mon, 27 Sep 2021 10:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632740335; h=from:from:reply-to:subject:subject: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=DU2tEKUAlY+ocYQsPyHaalbfi4Dl+tChnbA8pJC5NVY=; b=FAI4nWvNQDraIzCzudkp7sv0Lt+2QjHGdkQ2ZsgIZnuC+HKxoLUZ/EDKhoS79hOawxITgV W6wKgartU27LnsAw/ao5yvY3bdLhN4hyfvxpNpKjDwpxp6VMA1FZW3iL8lBYxQ/SkwjLAW piLlsJH477wuCZtBF8ksFbAOm8evwl8= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-103-dhHMItthOo-5ZhuuKyz0Ow-1; Mon, 27 Sep 2021 06:58:54 -0400 X-MC-Unique: dhHMItthOo-5ZhuuKyz0Ow-1 Received: by mail-wr1-f69.google.com with SMTP id m1-20020a056000180100b0015e1ec30ac3so13938310wrh.8 for ; Mon, 27 Sep 2021 03:58:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=DU2tEKUAlY+ocYQsPyHaalbfi4Dl+tChnbA8pJC5NVY=; b=miwLQtGgJ4YD1Uw5XnE90gek4CRq6fjbvbGbGys8rWK4unHmRKcasLt+GexJhOj/+P dkG2DrQ/gTREOifKyrjScWD9CLWT4zCCs9+8ACi5vsSc1rL8JmSYVndLCVQX+zIQzEBV HcZUw1S0zasrukloKjf5ForSVrv43xtn13BxhGN5yrvjkXbz208RYJDT3Y1ELEzHz2nD CtrDMewYgb0hSmcaoSsuT8GdiOnUj7eiyD2t3xwat2cm4Q96g/g5VxPKjK5Jj6QkDO8j 4wthcqwbk4/0NwaWRunLsNKTm/YRiYmaLNMpIED2gYq7qUBSe4rGKI1+57dqkWp03gdO 78ug== X-Gm-Message-State: AOAM531l1S67grSYhjJ+xlAFj3+Wq8JXtZiNHpDoqlucp5jNBPdweqnv 2AGooM232mFmvsebWI3sm5/BQNJwp3Gt9pwbMbhcN6GGcDEcE8ig5W8dS7rw6xNTPvLgBWTbTjG e9f5pOlud2U0= X-Received: by 2002:a5d:510b:: with SMTP id s11mr26530707wrt.79.1632740333640; Mon, 27 Sep 2021 03:58:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyHr82sy5zMMJXOCRj4t1rZ7szWVDTeIxrDOVbQcYPewiT/8p5Ja0ykY8XorKK8O1oAU8gtQ== X-Received: by 2002:a5d:510b:: with SMTP id s11mr26530684wrt.79.1632740333417; Mon, 27 Sep 2021 03:58:53 -0700 (PDT) Received: from [192.168.3.132] (p5b0c654d.dip0.t-ipconnect.de. [91.12.101.77]) by smtp.gmail.com with ESMTPSA id w21sm2755866wmk.15.2021.09.27.03.58.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Sep 2021 03:58:53 -0700 (PDT) To: Nadav Amit Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Peter Xu , Andrea Arcangeli , Minchan Kim , Colin Cross , Suren Baghdasarya , Mike Rapoport References: <20210926161259.238054-1-namit@vmware.com> <7ce823c8-cfbf-cc59-9fc7-9aa3a79740c3@redhat.com> <6E8A03DD-175F-4A21-BCD7-383D61344521@gmail.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [RFC PATCH 0/8] mm/madvise: support process_madvise(MADV_DONTNEED) Message-ID: <2753a311-4d5f-8bc5-ce6f-10063e3c6167@redhat.com> Date: Mon, 27 Sep 2021 12:58:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <6E8A03DD-175F-4A21-BCD7-383D61344521@gmail.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 7CC4D801A89F X-Stat-Signature: fs8zd6fa5mgzdpdhbyc6s8p63e613t3h Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FAI4nWvN; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf06.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com X-HE-Tag: 1632740336-495488 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 27.09.21 12:41, Nadav Amit wrote: >=20 >=20 >> On Sep 27, 2021, at 2:24 AM, David Hildenbrand wrot= e: >> >> On 26.09.21 18:12, Nadav Amit wrote: >>> From: Nadav Amit >>> The goal of these patches is to add support for >>> process_madvise(MADV_DONTNEED). Yet, in the process some (arguably) >>> useful cleanups, a bug fix and performance enhancements are performed= . >>> The patches try to consolidate the logic across different behaviors, = and >>> to a certain extent overlap/conflict with an outstanding patch that d= oes >>> something similar [1]. This consolidation however is mostly orthogona= l >>> to the aforementioned one and done in order to clarify what is done i= n >>> respect to locks and TLB for each behavior and to batch these operati= ons >>> more efficiently on process_madvise(). >>> process_madvise(MADV_DONTNEED) is useful for two reasons: (a) it allo= ws >>> userfaultfd monitors to unmap memory from monitored processes; and (b= ) >>> it is more efficient than madvise() since it is vectored and batches = TLB >>> flushes more aggressively. >> >> MADV_DONTNEED on MAP_PRIVATE memory is a target-visible operation; thi= s is very different to all the other process_madvise() calls we allow, wh= ich are merely hints, but the target cannot be broken . I don't think thi= s is acceptable. >=20 > This is a fair point, which I expected, but did not address properly. >=20 > I guess an additional capability, such as CAP_SYS_PTRACE needs to be > required in this case. Would that ease your mind? I think it would be slightly better, but I'm still missing a clear use=20 case that justifies messing with the page tables of other processes in=20 that way, especially with MAP_PRIVATE mappings. Can you maybe elaborate=20 a bit on a) and b)? Especially, why would a) make sense or be required? When would it be a=20 good idea to zap random pages of a target process, especially with=20 MAP_PRIVATE? How would the target use case make sure that the target=20 process doesn't suddenly lose data? I would have assume that you can=20 really only do something sane with uffd() if 1) the process decided to=20 give up on some pages (madvise(DONTNEED)) b) the process hasn't touched=20 these pages yet. Can you also comment a bit more on b)? Who cares about that? And would=20 we suddenly expect users of madvise() to switch to process_madvise()=20 because it's more effective? It sounds a bit weird to me TBH, but most=20 probably I am missing details :) --=20 Thanks, David / dhildenb