Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1652498pxp; Thu, 17 Mar 2022 13:39:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7kkTlp+gX7Ka1vc4Yy0VNUfFa4s1MzCLTh00IOFjHLDbLxMrBbeX1ZtI84t1z2BFsEmbf X-Received: by 2002:a17:902:f64d:b0:151:3895:46bf with SMTP id m13-20020a170902f64d00b00151389546bfmr6572758plg.31.1647549594583; Thu, 17 Mar 2022 13:39:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647549594; cv=none; d=google.com; s=arc-20160816; b=HnV7OjgRN48LmSgtdMU59UlVa7Aa06PozbMzjSqx6oXSCVqUIOyeiXZHoPYtnQkc4T U+i+DN/i5NHHChmUc+JqPaDk5Ztv/bOIRDzSTZS0ZRHPAaMgyQZdGmXLZb18tgtlZXgd n40qtLlSAEra2g/uB5fj6o0ilc4s3wfQ0QtPWHdCyazaXN22Oj/m8XsyMWHra3yoMWM7 yJVV0OKpWMKUgutpGrk2e+cYcMRZvtVecQR2BNJd2tVhy03d5vk2lSRvtcTFA+ne0foj dIQi5ciI7mpUhblaFT3aoHgOz3L+Ej95qKPek4TwZjSFGkZReuUzT11HCEuCmXQnAo8j cGRQ== 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=FpjeJ8QdW/CmqR2xDeXs/92h46wSWjFSBCozUg7uNqs=; b=IHihlIpWaP0Cb6Gso+MwY1ij6NLXCQ81bSGFM1sVEo755NbowvfQHBT45/UJrjEt7o 1Qc2t1xutoGjuf23DLLXv0QgwiKZj734NbALUxtW+Z4LdAyhoN7HKhXYP8aRSNUqX5/g dR7KbruAVrBGPxQFysMegpy66J+H7dTo10COOeEnSdH++vuA7DN66P4ekPNxm7LFGFaM q+//Idv8MmdqZZz3VmhQfWBogGuvuQBfW3McKcfPIelCm9lzv3QjLgczvPG5YE0gSv3G F/BzZFjxaoZQyxpq2f/BlNmHG/H1QIB4+KdkAt4ds2tKLJVjUG+m9JAnNKi+6t+6FBIY 5Adw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=gTvdJVxU; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 198-20020a6301cf000000b003816043eefbsi2996081pgb.240.2022.03.17.13.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 13:39:54 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=gTvdJVxU; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EE254163E0D; Thu, 17 Mar 2022 13:08:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236681AbiCQQyh (ORCPT + 99 others); Thu, 17 Mar 2022 12:54:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231928AbiCQQye (ORCPT ); Thu, 17 Mar 2022 12:54:34 -0400 Received: from mail-yb1-xb2c.google.com (mail-yb1-xb2c.google.com [IPv6:2607:f8b0:4864:20::b2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A12B62A37 for ; Thu, 17 Mar 2022 09:53:18 -0700 (PDT) Received: by mail-yb1-xb2c.google.com with SMTP id y142so11272799ybe.11 for ; Thu, 17 Mar 2022 09:53:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FpjeJ8QdW/CmqR2xDeXs/92h46wSWjFSBCozUg7uNqs=; b=gTvdJVxU5LXYliDDCmEWbkrnko0Ce8YhCfpPalJdRHYuKPj+8//gr2BTDR8yZuyx79 4oCQWvQSP8YEA5A7vu1LShb0QVL7Fcaqv6rdI6MeqhbdOKifbeY3D9tZPurpvUX2Xs+5 kQEl8nMNYOnXuBSo+pLVwAsTPHgEY7lyEtP/MS7BOXxzJlMY7i3URcR4m/pNAqDSn+6V BhvslQJFvA1k9FvAAb/rqBCGb4LNeyyjqO5S6J4988CUISzgL8FadrAqSPvORUKSVE06 OHjLmZq38EpO1GILzdeg00H+5f064X0Dm0gKV/6+BKBK91tCsw6CwDPP1bTQqomXh+51 vY+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FpjeJ8QdW/CmqR2xDeXs/92h46wSWjFSBCozUg7uNqs=; b=cadTiFvW5wKSTpPfk7gbLhkoyG/a135b5KMCXwcrBuA+6K4px/RSWFlQYU+RT752z3 DmkepCyw+vQZ6m3gNjLFQjFYUb+t7KITcQtvfGTx8bjfCncftlP44fSiyq9T6TdYkYow rp9dLP4yvAjjCaAK/hv4m5CZ89cnNAG1SuxSmw8HEa/Qv1OElegOIm08u/cplKMFklNG EUQTkkh3o4NJ9ErGCR+aS9MbFQSEt8pJiRfUUtfpTpKNeTiULZzW/szAeEoFLpqo6lfU /xDflj8wNLows5r2GSNF9deotGHpDK5t7NqXCGo+eL8y05AeFPwI10Re6cWermo32Zdg bv/w== X-Gm-Message-State: AOAM532OXPiZvxZR4BZ4Z808cd9uznRjQuQrZkdxR6UpwE4+3OK6y7hM Wgp/0F9+ZaP0umCVjym8zne2B6MJM/SzTEqREpCP5A== X-Received: by 2002:a25:1906:0:b0:61d:9576:754e with SMTP id 6-20020a251906000000b0061d9576754emr5795294ybz.426.1647535997540; Thu, 17 Mar 2022 09:53:17 -0700 (PDT) MIME-Version: 1.0 References: <4f091776142f2ebf7b94018146de72318474e686.1647008754.git.quic_charante@quicinc.com> <20220315164807.7a9cf1694ee2db8709a8597c@linux-foundation.org> <5428f192-1537-fa03-8e9c-4a8322772546@quicinc.com> <20220316142906.e41e39d2315e35ef43f4aad6@linux-foundation.org> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 17 Mar 2022 09:53:06 -0700 Message-ID: Subject: Re: [PATCH V2,2/2] mm: madvise: skip unmapped vma holes passed to process_madvise To: Minchan Kim Cc: Andrew Morton , Charan Teja Kalla , Vlastimil Babka , David Rientjes , Stephen Rothwell , =?UTF-8?Q?Edgar_Arriaga_Garc=C3=ADa?= , nadav.amit@gmail.com, Michal Hocko , linux-mm , LKML , "# 5 . 10+" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 17, 2022 at 9:28 AM Minchan Kim wrote: > > On Wed, Mar 16, 2022 at 02:29:06PM -0700, Andrew Morton wrote: > > On Wed, 16 Mar 2022 19:49:38 +0530 Charan Teja Kalla wrote: > > > > > > IMO, it's worth to note in man page. > > > > > > > > > > Or the current patch for just ENOMEM is sufficient here and we just have > > > to update the man page? > > > > I think the "On success, process_madvise() returns the number of bytes > > advised" behaviour sounds useful. But madvise() doesn't do that. > > > > RETURN VALUE > > On success, madvise() returns zero. On error, it returns -1 and errno > > is set to indicate the error. > > > > So why is it desirable in the case of process_madvise()? > > Since process_madvise deal with multiple ranges and could fail at one of > them in the middle or pocessing, people could decide where the call > failed and then make a strategy whether they will abort at the point or > continue to hint next addresses. Here, problem of the strategy is API > doesn't return any error vaule if it has processed any bytes so they > would have limitation to decide a policy. That's the limitation for > every vector IO syscalls, unfortunately. > > > > > > > > > And why was process_madvise() designed this way? Or was it > > always simply an error in the manpage? Taking a closer look, indeed manpage seems to be wrong. https://elixir.bootlin.com/linux/v5.17-rc8/source/mm/madvise.c#L1154 indicates that in the presence of unmapped holes madvise will skip them but will return ENOMEM and that's what process_madvise is ultimately returning in this case. So, the manpage claim of "This return value may be less than the total number of requested bytes, if an error occurred after some iovec elements were already processed." does not reflect the reality in our case because the return value will be -ENOMEM. After the desired behavior is finalized I'll modify the manpage accordingly.