Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5496806pxu; Tue, 22 Dec 2020 20:14:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxhqmpTPr7RTMPYsunWfiJ6VtMv6ldKVzo/GGuvRkmWEdZ4fdjgcqfe35IUxfPqZCd9oJYC X-Received: by 2002:a17:907:20dc:: with SMTP id qq28mr22442645ejb.403.1608696841299; Tue, 22 Dec 2020 20:14:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608696841; cv=none; d=google.com; s=arc-20160816; b=iYqB/lN/rqtomDYVTwQt+Wf6qG/4TbCd2naplf/q7bndyfIV7mW0Fb5rLXPKacwK7l nrfw3JN4/w33dNZEdtT/+1jM9s2kF80yfFgmxmLG0by0cMTOAQ4pm6+WVgbePDaJiubS 70/duss3Cn3pFVqfEUEX5mD36Ov718X5v5ue7JtxDsuRW6k2iK6KuPhS98W4eLmzU94I RdNNUGIBOz9eNl8xwzGVXoHW2lfqFy/4iiNy1q/VYOnWEBCjMhtaEGdw4dU5Ac2JW3oh TyOiklvyKshs1eljAhG9Xi1ykz8Ln2YCCy+Qqy9WC8ELS9n8VwwmvVFjgqmIlNzJuWex ODzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=mEKgkwouOKYZHcH4n91a1kSOJQB4OjAj1Ym6t3oLUZg=; b=MTWNLGdLlJ9Vq/bN3DhrTeicch9hQFrXlPQbEQjTQjdgWicnKipl/h82zwCbefZyKx V+4qRMwsK1YcrDhMAnqVQ60I0ZsA4VPn7GrBesSVdNSQkz9tDuHqdCRW46ksx3yLo6YN UR7P5SyoPMFTXk3/p/1eoYt0UWHkq3B3ZHWcdFHUnxxKriKZu6Wv2FqpkyKxLrzqk0sD YffVP0namT6QL069+qEhwI5g8NGDUvFK5ISKXeLhzsnH4xHXj3DvTBvlBDWVF+TvkNA9 ux8gw8gbBwfk6SD7uHSqV2E7bDPu0TVcLpThXviUyEQdmJfdbq1HMpkUF/IUjNX4f3R2 9ZCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GCyHsTtM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gs31si10708000ejc.337.2020.12.22.20.13.39; Tue, 22 Dec 2020 20:14:01 -0800 (PST) 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=@google.com header.s=20161025 header.b=GCyHsTtM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727207AbgLWEKK (ORCPT + 99 others); Tue, 22 Dec 2020 23:10:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725938AbgLWEKK (ORCPT ); Tue, 22 Dec 2020 23:10:10 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71C92C0613D6 for ; Tue, 22 Dec 2020 20:09:29 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id r4so4940536wmh.5 for ; Tue, 22 Dec 2020 20:09:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mEKgkwouOKYZHcH4n91a1kSOJQB4OjAj1Ym6t3oLUZg=; b=GCyHsTtMvVF+o0PPsA9JOPc3Tnap8ECvAQEXYjF1qfaHhpND1UDgZGZY54wH3DSJF9 rWvR5SZg28KD8mt7NHlrhrqiRwCvOF3vWW3jo7RjGssZseK0AouuXu6+RVP4L+SuYKWZ VwOonhik47uTNWOY9g5gfYlYGlbWKunaKQHPKC8Mbv3JpuHIIoBpZaDwBxYYOhsXhDOI zlFxpJ9p1pcGczqiEmYv+1EceIPb+YuY3YEuoUjdlZ9/elsrOxTQP+PPC9m+ha1ARkki tFNJQvtfsq6BAF6GjPP59m139vYLQMPjbS0zyg2Hqp3AV7VEglVdijZYENSyzPnMzQvn GO3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mEKgkwouOKYZHcH4n91a1kSOJQB4OjAj1Ym6t3oLUZg=; b=HA+C341IpkCKdoFBtq2bY+stdFmTd9FPbPb+3HN2KFgAGtQaZnPfphN7FHamE5uThn mCZRWaxjLIjC99x0ExNx11RsSD1Ey8ZW3uRxLHO5IG0tyEvsujqc1Y/NXSCmlHpZei/R ztZTIPXYfUK1ZzQf14oKGYRHhoMmymahTYuHLJhq/B7LTMzqcV39scos6xTlsvRKlB6I m/yILihgZ7OIdK9h0EzsXO76gsjSNmbdA3WCHSEHEH6AmMlylZSmeF9ebyupWICjoplx SMOK5SsuV2yQppWTNKGM4LRTO2T3TE7s+sxNxcMkU1dW5DXoKvbtycKvo07OJX/07wa3 rCQA== X-Gm-Message-State: AOAM533C0RQO7Y3ggFCSz3AQBFaZwbSip6RyJIf0GhWKNeSiJ5IJ3qJC 49G2/eNoMDVlZDLY2vF5yFlF9Cw/VU7uJtnyto56mg== X-Received: by 2002:a1c:bc57:: with SMTP id m84mr24633253wmf.163.1608696567336; Tue, 22 Dec 2020 20:09:27 -0800 (PST) MIME-Version: 1.0 References: <20201124053943.1684874-1-surenb@google.com> <20201124053943.1684874-2-surenb@google.com> <20201125231322.GF1484898@google.com> <20201222134438.GA7170@infradead.org> In-Reply-To: From: Suren Baghdasaryan Date: Tue, 22 Dec 2020 20:09:16 -0800 Message-ID: Subject: Re: [PATCH 1/2] mm/madvise: allow process_madvise operations on entire memory range To: Christoph Hellwig Cc: Jann Horn , Minchan Kim , Christoph Hellwig , Andrew Morton , Michal Hocko , Michal Hocko , David Rientjes , Matthew Wilcox , Johannes Weiner , Roman Gushchin , Rik van Riel , Christian Brauner , Oleg Nesterov , Tim Murray , Linux API , Linux-MM , kernel list , kernel-team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 22, 2020 at 9:48 AM Suren Baghdasaryan wrote: > > On Tue, Dec 22, 2020 at 5:44 AM Christoph Hellwig wrote: > > > > On Fri, Dec 11, 2020 at 09:27:46PM +0100, Jann Horn wrote: > > > > Can we just use one element in iovec to indicate entire address rather > > > > than using up the reserved flags? > > > > > > > > struct iovec { > > > > .iov_base = NULL, > > > > .iov_len = (~(size_t)0), > > > > }; > > > > > > In addition to Suren's objections, I think it's also worth considering > > > how this looks in terms of compat API. If a compat process does > > > process_madvise() on another compat process, it would be specifying > > > the maximum 32-bit number, rather than the maximum 64-bit number, so > > > you'd need special code to catch that case, which would be ugly. > > > > > > And when a compat process uses this API on a non-compat process, it > > > semantically gets really weird: The actual address range covered would > > > be larger than the address range specified. > > > > > > And if we want different access checks for the two flavors in the > > > future, gating that different behavior on special values in the iovec > > > would feel too magical to me. > > > > > > And the length value SIZE_MAX doesn't really make sense anyway because > > > the length of the whole address space would be SIZE_MAX+1, which you > > > can't express. > > > > > > So I'm in favor of a new flag, and strongly against using SIZE_MAX as > > > a magic number here. > > > > Yes, using SIZE_MAX is a horrible interface in this case. I'm not > > a huge fan of a flag either. What is the use case for the madvise > > to all of a processes address space anyway? > > Thanks for the feedback! The use case is userspace memory reaping > similar to oom-reaper. Detailed justification is here: > https://lore.kernel.org/linux-mm/20201124053943.1684874-1-surenb@google.com Actually this post in the most informative and includes test results: https://lore.kernel.org/linux-api/CAJuCfpGz1kPM3G1gZH+09Z7aoWKg05QSAMMisJ7H5MdmRrRhNQ@mail.gmail.com/