Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5165906pxu; Tue, 22 Dec 2020 09:51:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzr6BeD1nxS30RFAWp8GpdZZFfOdzeDTrtoAC1DBmUV+xWkQXQc40J5jAuQ4DfZj2Beqs3V X-Received: by 2002:a17:906:298c:: with SMTP id x12mr20784740eje.244.1608659467270; Tue, 22 Dec 2020 09:51:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608659467; cv=none; d=google.com; s=arc-20160816; b=xJfCYL4GSJCyzKwWH9JLucJNAylgFfo7yXEy7E1SA+o0QscTIbSb8Yjij+sEi3HS0/ zrQyb9xq9ab+FNMMaaasxJZ+d4OeaYY3uWhiTc0JwRFj1AIGOGUj50UU86Ayqys4Pqm3 zO2Kc9Ye+G3ezwUsrWmhcvoov4RCszJBz0UM4sHMPu3li3MxHaKbKZ6U/VrhvXITVdR9 8Q3Iguwx0DTYan7PuYt/8Ts5ld3gLHWN+gqstbqhIQsYAwW22z/95jrsTjrYI/LMMrZm AffJczTcNxUqhGWOEWLWPLeHHDqVQUbWZhPeynKWTGdYeEQy56jeSNhxy5srHPiwUCN8 iRhw== 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=gZ3Mpnz+y+y40eMwZF/PF9p0ykrXNof+TnqSLHPYMc4=; b=TMIr+CvGyno7NQEGMdvPGWhR+kjI1khoG35benRiar5LEu/slr7kNUD9dC61+RQtAd N70copc2elmwjxygWF75DXZKaCLejXcNVpteQWM/gd3NJnNMwys789X5vUvZkhzouN/L VDL8Xkb6XNTOjZB4rmrIqs5axKRPUDB8stp2/gThLoqwP4PipIC7EW8lFKWmUxTQGbXM k8pLp21JLudIw9M5+qJ0/prLBdZUyX87xkkPW2Bk+Kq2DZAnlRoZ0EBSepL87Va51Ytp AtwWzxNHTMpKhOsyDzrk+MwIAJpq4CEBEc6ZkmuBbyBAh9YWNhGV3DoAGKvL4nh/rPFN vpGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fJurTTnF; 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 q10si12176874eds.293.2020.12.22.09.50.44; Tue, 22 Dec 2020 09:51:07 -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=fJurTTnF; 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 S1728096AbgLVRtg (ORCPT + 99 others); Tue, 22 Dec 2020 12:49:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727962AbgLVRtf (ORCPT ); Tue, 22 Dec 2020 12:49:35 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77344C0613D6 for ; Tue, 22 Dec 2020 09:48:55 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id e25so2960287wme.0 for ; Tue, 22 Dec 2020 09:48:55 -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=gZ3Mpnz+y+y40eMwZF/PF9p0ykrXNof+TnqSLHPYMc4=; b=fJurTTnF+Va0FHUdyTWNlS1cGpvh5djyhWHIz8cfeXiEfOyaHauqRQAM7CWWF/HB4r XIFtvR6qpYy5MgmX/TledRqo+t3vH2fcKr7e38xsmzAyKFWgAU8vhI2ZUIFIAYsEkZ8p a1YloLSV7hKc5+Gwt6KP7k500IbltONvgsDcSeGi9zSpQg8zA7YgsqoHX5zOYwp5BF/e iW/jP7UOFR0ATiu/JRaMsx7mEMPFpD1OoYVYpfMH/SAtbBGfvYXc6oIG88gZL0BbXR1o FAp5U+WxGka2LA/evqmWwrzWueuV0cQwOyeE9XZRiQIJnFQm1w0/OvkqpZyWL+tQoCmU sZBQ== 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=gZ3Mpnz+y+y40eMwZF/PF9p0ykrXNof+TnqSLHPYMc4=; b=L5vlK9vrmlP63ZcgITfwJjnl7GVUb0vMne8fIEg3ZqQp1FhtMF6aEyViRRViJH+Jfp PALS55PlrnyO6Wcqo6Y76hnrmWKt6hBp37FbovlS+U6FobvWYKqwtjrKrNgYqtd7Nhru 0XJngKJtQ5qfONqHFOc/Ig8BoAOtyw9UzTPgm23sCg0bOOZ3jI029877GFKZYUPhhNMZ u2BTgSQeexV5AIyH5NMgfd+RdHmDYvxk9YO1F74sGK8D9mekc6ChoDwVn2XbuGtTqlKX uRlqBzOOaZgTZX+lVdfMFyb1nBdj39EozJ7XZebJZZ26tGzfnXHlSLPG7zJw4eiL4d2T r6gA== X-Gm-Message-State: AOAM532ZrxWx3MAYEFAq7yJHYIhZVCOjz9AD5kNAqR47jAeP4okQltdN 2uS0+jXWdFQELq5QOQ95RaEBV8MO4PrD32VTZaFt4w== X-Received: by 2002:a1c:4e0a:: with SMTP id g10mr22732565wmh.88.1608659333913; Tue, 22 Dec 2020 09:48:53 -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: <20201222134438.GA7170@infradead.org> From: Suren Baghdasaryan Date: Tue, 22 Dec 2020 09:48:43 -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 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