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 X-Spam-Level: X-Spam-Status: No, score=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC1E5C433E0 for ; Wed, 23 Dec 2020 04:09:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 65CD12231F for ; Wed, 23 Dec 2020 04:09:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65CD12231F Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D38308D0018; Tue, 22 Dec 2020 23:09:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CE75E8D0015; Tue, 22 Dec 2020 23:09:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB0C38D0018; Tue, 22 Dec 2020 23:09:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0162.hostedemail.com [216.40.44.162]) by kanga.kvack.org (Postfix) with ESMTP id 9E7978D0015 for ; Tue, 22 Dec 2020 23:09:29 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6B906181AEF32 for ; Wed, 23 Dec 2020 04:09:29 +0000 (UTC) X-FDA: 77623217658.07.crack33_3a0dc4c27465 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 4E7A61803F9AE for ; Wed, 23 Dec 2020 04:09:29 +0000 (UTC) X-HE-Tag: crack33_3a0dc4c27465 X-Filterd-Recvd-Size: 5648 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Dec 2020 04:09:28 +0000 (UTC) Received: by mail-wm1-f53.google.com with SMTP id g185so4946138wmf.3 for ; Tue, 22 Dec 2020 20:09:28 -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=D/vDoQwQ5ZftBKMeuadWXKc327wtAMUg6LgTSRKHAyLrb1LRz5lrxMlxu+u+9aYpAV 2U0EoQ7UE5knDgG7YBJm5mFar8ZbzJ4ZCaHNlCqw7hceyhkVi4i63qIyj8qqnjkk+28V FwSt50fA9HmejceePYggiXz8HJuFUSvzCnUJo/X22hz5kMAT015tQ8pycU26QGJCKzS4 2lFPc3cXV4Ht7AaQu+yw+7XyX4fEKPLbWKYZ5xdEvMXNdymLj+eVx73JzUN+5PippmJE mu9Y6hFB6nV2USGrUtz82JZ1YiDe6D1UGoycMmvCRdbPDAdd3cCuquo/IaIU4V0nszn+ /j7g== X-Gm-Message-State: AOAM531HA1r6r6J0/CJG4yoB4KYZw0Pfes+Q6fdmemH9zRpYR7sX5cRm s95d/Wjzh8gcIqxISaxvlEBTqy5bzVHM83Pl7bCeqA== X-Google-Smtp-Source: ABdhPJxPVdCgx7+QCZCFCNYd3eHZZxJkjYTnkoaSbYlibmLYDpD+CjFqTDwkRlBahO8dCv8H6X9PKIFxzwatSmNQQEk= 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" 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 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/