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=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 03B8FC6379D for ; Wed, 25 Nov 2020 23:43:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4C96420872 for ; Wed, 25 Nov 2020 23:43:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g9BQfhCo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C96420872 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3354B6B006E; Wed, 25 Nov 2020 18:43:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E3D96B0070; Wed, 25 Nov 2020 18:43:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D13D6B0071; Wed, 25 Nov 2020 18:43:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0068.hostedemail.com [216.40.44.68]) by kanga.kvack.org (Postfix) with ESMTP id 04E946B006E for ; Wed, 25 Nov 2020 18:43:28 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C1F653630 for ; Wed, 25 Nov 2020 23:43:27 +0000 (UTC) X-FDA: 77524569654.26.glue72_200d2af2737a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id A59CD1804B65C for ; Wed, 25 Nov 2020 23:43:27 +0000 (UTC) X-HE-Tag: glue72_200d2af2737a X-Filterd-Recvd-Size: 6219 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Nov 2020 23:43:27 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id w4so89494pgg.13 for ; Wed, 25 Nov 2020 15:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=bQYnjhL0stRqsuyZnoj4uO3ieagz/79UtzcnmbDad6s=; b=g9BQfhCoDg8rHX2/STPOQSCULFMxCVHtLH+m7w2TQC+3YZLzjBdtDSx5hSmNUHH2BM ViQQ9ovPWt2dCOE6blxmwtXDQLyJWhHThOLDxC02yakybbfpZ4Nvgtit5PpOk9Kzgm0+ NZrv4z6wcNuCFxFedO8YWTNmCnSL2q147J+v6SVu576fgd4QllvLDr4efTKnGjna0vCE fMiePrg1EC2xjjSiDPsh4SLFllZ2xj0uEoipp7T40z/LzO8NgwY1BT6r3u1SVd+7/vTx 7im50bf/847dbrNh81Z1J8YXTX44lAMzknn162Yp9j8eqbwrz01c7i/mmp1MG2rcJovE b2Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=bQYnjhL0stRqsuyZnoj4uO3ieagz/79UtzcnmbDad6s=; b=PI88QKTWIDjzVdqJNbOM5CTxGUjDhJf95u4AwwqAebvmPnIAGXWcH5hXPnF74kABYH Ic/iApKDCxSf4yYAHKo9VUylki28jQum+xZYLwzl9OLs6PDvNUXYqKTq5H4i5g8F2kfE 5DrHjP8ALKxom2mLLj6jAqHTePXEZ37zfju5PdeDzEi8vJiFm2fOYHpu3dvsQC2XTsSj 51lAmKzvXO4ENuJixAR5/Tqss3az7mOavA057mA0eHGsDYmimIP1Ndeh0ycsDItoMxUU sRJuVQ7FdvB0fkk2ylognz9WMI5sbkls3YnZSRvMxbcX8DJmizxhA0gviFnZuYtHX2x1 IRfQ== X-Gm-Message-State: AOAM533X4V7ETPL1IBGy5UNxQawEZTbsVjl/l6zqukf739YjSS7k7LSJ E125XBCkGBtOANpt4bwXzzA= X-Google-Smtp-Source: ABdhPJx6wng91PMAdMoNOKNRWJ5AbARmgJMXsqWGoOyveeV0KdmGQvix9JhD+VHflR2ilSZgYUi8eQ== X-Received: by 2002:a17:90a:fe88:: with SMTP id co8mr241177pjb.76.1606347806124; Wed, 25 Nov 2020 15:43:26 -0800 (PST) Received: from google.com ([2620:15c:211:201:7220:84ff:fe09:5e58]) by smtp.gmail.com with ESMTPSA id y20sm2866194pfr.159.2020.11.25.15.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 15:43:25 -0800 (PST) Date: Wed, 25 Nov 2020 15:43:22 -0800 From: Minchan Kim To: Suren Baghdasaryan Cc: 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@vger.kernel.org, linux-mm , LKML , kernel-team Subject: Re: [PATCH 1/2] mm/madvise: allow process_madvise operations on entire memory range Message-ID: <20201125234322.GG1484898@google.com> References: <20201124053943.1684874-1-surenb@google.com> <20201124053943.1684874-2-surenb@google.com> <20201125231322.GF1484898@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Wed, Nov 25, 2020 at 03:23:40PM -0800, Suren Baghdasaryan wrote: > On Wed, Nov 25, 2020 at 3:13 PM Minchan Kim wrote: > > > > On Mon, Nov 23, 2020 at 09:39:42PM -0800, Suren Baghdasaryan wrote: > > > process_madvise requires a vector of address ranges to be provided for > > > its operations. When an advice should be applied to the entire process, > > > the caller process has to obtain the list of VMAs of the target process > > > by reading the /proc/pid/maps or some other way. The cost of this > > > operation grows linearly with increasing number of VMAs in the target > > > process. Even constructing the input vector can be non-trivial when > > > target process has several thousands of VMAs and the syscall is being > > > issued during high memory pressure period when new allocations for such > > > a vector would only worsen the situation. > > > In the case when advice is being applied to the entire memory space of > > > the target process, this creates an extra overhead. > > > Add PMADV_FLAG_RANGE flag for process_madvise enabling the caller to > > > advise a memory range of the target process. For now, to keep it simple, > > > only the entire process memory range is supported, vec and vlen inputs > > > in this mode are ignored and can be NULL and 0. > > > Instead of returning the number of bytes that advice was successfully > > > applied to, the syscall in this mode returns 0 on success. This is due > > > to the fact that the number of bytes would not be useful for the caller > > > that does not know the amount of memory the call is supposed to affect. > > > Besides, the ssize_t return type can be too small to hold the number of > > > bytes affected when the operation is applied to a large memory range. > > > > 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), > > }; > > > > Furthermore, it would be applied for other syscalls where have support > > iovec if we agree on it. > > > > The flag also changes the return value semantics. If we follow your > suggestion we should also agree that in this mode the return value > will be 0 on success and negative otherwise instead of the number of > bytes madvise was applied to. Well, return value will depends on the each API. If the operation is desruptive, it should return the right size affected by the API but would be okay with 0 or error, otherwise.