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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D43AC433F5 for ; Thu, 17 Mar 2022 16:53:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E034B8D0002; Thu, 17 Mar 2022 12:53:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB4428D0001; Thu, 17 Mar 2022 12:53:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA2318D0002; Thu, 17 Mar 2022 12:53:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0019.hostedemail.com [216.40.44.19]) by kanga.kvack.org (Postfix) with ESMTP id B339C8D0001 for ; Thu, 17 Mar 2022 12:53:19 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id EEB3A8249980 for ; Thu, 17 Mar 2022 16:53:18 +0000 (UTC) X-FDA: 79254473676.28.1AFEEE6 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by imf07.hostedemail.com (Postfix) with ESMTP id 7C3BF4000F for ; Thu, 17 Mar 2022 16:53:18 +0000 (UTC) Received: by mail-yb1-f178.google.com with SMTP id z8so11324497ybh.7 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=66ZkH3yv86XsCi0Z9JyhEXwx8TYzF+2VRRF6i/NdMceewkB/yjTkvTotm70OxpFywk eR5aST9tyO0wgo8nPRypiLd1o5eXMF4BbJEF2zy1rcuqZajFnPVk+Rb3xQZwuDxnebSC 7FNyZZZ9B/cLXhJzp3gLLiox4njR8V4C7JBw+yGXWIAvbn+bNRfCjWHaikw+s3sSm66T TJgHDoBkbJ7ez+7hnEpsK9+p/mkzK48uk199/tafLjKe7VBuJVrle4fl4+9k+G84t7qf Xir/pbMOLyJBdbbpCvnR2NpHQwW7GY9/CM7j99fZiqBFjCs5z1X0RqcT6h/HWMkG/O68 33HA== X-Gm-Message-State: AOAM533+ci+L8epWhXvJDC2Wsohg2g6feKHYWKlrL8UhXUJlaQSPCHgw q+c9qaR70wuJoWuFuq6cMbbj1iYC1W1njO3gb8KIVw== X-Google-Smtp-Source: ABdhPJyJYSYDZjLCDSULZ1P1ZZ5vjZFLsDMYo99t43UMgeiqWKfG6cxaG3yU+sgeECqkvltfODNP3glHpXcKDREAQnU= 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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7C3BF4000F X-Stat-Signature: q6efiwkn1zbjd58tgghqpq3togomuy9z Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=gTvdJVxU; spf=pass (imf07.hostedemail.com: domain of surenb@google.com designates 209.85.219.178 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1647535998-259700 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 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.