Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp729188pxb; Tue, 2 Feb 2021 16:56:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJytFQkl4Lfk0zHbSrdxZieCUdFvGtP+RStdzclrDOBdriusR9dS9VPYQ4lpbM+fUHnssGgS X-Received: by 2002:a17:906:b106:: with SMTP id u6mr607445ejy.313.1612313774756; Tue, 02 Feb 2021 16:56:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313774; cv=none; d=google.com; s=arc-20160816; b=NlmI0WF222PwA7EqeLGkgxfVGg8mAAsoMeC+HBRv/qpOxNuQKaSSymJv9Oj9gQmwC9 F70/BNKWyaMPyo2gJZCtq/U5S2/mNIowRiAj0uLCyrcixhczoRNk3ZGnPlp2lv+uy2rC 6R08D2TJmQfShLqbF+GjpOaBdrAP1XoSCSk4OrQAMuSGDf+XFsa30Xwo7O4ASIG1zsxX Fol0FbHiLIPjXsNpW0/VCM0otRrt1U4banI12iLcVO7Qe1Wm7jjhLM9Co5Gh4d5ANZ2j AKHcDwqPl6odxPlklwsPqknTtOqKoXtTfnaxgpJ5b06UySl/Obo5yyoJXHl2ovtjjV9j FkxA== 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=xqP0a66Os6f9sXyF+kMsv13PEbv0LhzI8V6aeWIM0Ok=; b=BNl8OCxx2+qfumqhWLL38AYTgXDxQYVHy3fci/qbGaZBYd/e34Rrf8WZb26e8U0YyE xKvZqB9zrTKAwbsi3J9+pAICXneUhsWCp4nSBijKUnvMAe5Wlj0oWoW9zvfCElgOppDU Ojk4jFm3mLvuTT1XEMYzTyJAXCSePTjHXYVqljsPq/aVLZaL3cgzQvXnydGLVIfr/js+ LtbpiCRAs97znHcl0iSY2NEMI9ou4vAddMtm9cBcBBiT6NVEml9xgKrWvo81PcFzS4YY jjaOaVH7DjoVbQWmnSft6z8DnNeQeA4Y5AKstH2ZFwgP+2OLg61NhO9EHgCBBfRgZzWd 6Sqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TPz3NwZf; 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 p63si316607edb.24.2021.02.02.16.55.50; Tue, 02 Feb 2021 16:56:14 -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=TPz3NwZf; 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 S234764AbhBBWNv (ORCPT + 99 others); Tue, 2 Feb 2021 17:13:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbhBBWNj (ORCPT ); Tue, 2 Feb 2021 17:13:39 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5584BC061573 for ; Tue, 2 Feb 2021 14:12:58 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id q7so22051097wre.13 for ; Tue, 02 Feb 2021 14:12:58 -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=xqP0a66Os6f9sXyF+kMsv13PEbv0LhzI8V6aeWIM0Ok=; b=TPz3NwZfJQX2n8XN2IcK3GG1+YdjmSwEfCGkkfB/R3l9sej3bWUpfbAM6RCQCZ7zSg wtMWuG93czJxsPaqc/vxVW5m5aofw7Xucq73fsummtWKzVU1OcRLPV1d4bpHrkbnQvc4 IGVMEw8sSzmZ9C62tJnk3nveiCu7uLVYsZYtvwViU06V6jZ65gHNw7E+q3Wxw3dk6eXe z5op6gObDb+ORYEdWZ3w4BYU3o2SvM5AHHBAGBxccLb/WJ/Qhq7WY8qKqMIPltmMJ5MP z66weUVMT+YCRplS4JltaxL/GEcdZbNO5Nz0syi3n8gD39XWVSSc8FUArjYvPDInNAiR z2yg== 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=xqP0a66Os6f9sXyF+kMsv13PEbv0LhzI8V6aeWIM0Ok=; b=B9fXH4C5o3I9ZtlkBHtsNccAvfwInPyGGqhQlS+SEblz63gpYO5YmRvWCCGgIXksvv joQLGHBNnI/NHDv6dBkKWO58HIn+IDtnmePOTcKHOdsHzkK0KCC5YCymacizYSB0i3pz 9mg4TD9M0UkkIfW9KwzazY+z1IzdB8ZzQ2QRYd9VJXw/DwHMzw+7nSDbWpRz0hxdt9BN 69WJ6dOYIxZe8ToxAtCwcKBbT0yX8A2bX20lrKartvj+34+7nZuTxWxfY5byOax4lS1L cA5CPdN+vUzZtO3fan8p8YfCcsE07hkM3PehoxzI51UsW9LSSxuC59dz7wZlyX039hKS LYyw== X-Gm-Message-State: AOAM530jD4hMhxqdQDUxAEtxzzTVIEBCisAuB4m6wOfDLo9p4l0M6ca6 XoX7087H4Gz6rABYkYysChTuRngiQYBXuJOJW/Q5Lw== X-Received: by 2002:a5d:6884:: with SMTP id h4mr218812wru.106.1612303976784; Tue, 02 Feb 2021 14:12:56 -0800 (PST) MIME-Version: 1.0 References: <20210202053046.1653012-1-surenb@google.com> <079db245-a08c-0dbd-01d4-8065f533652e@gmail.com> In-Reply-To: <079db245-a08c-0dbd-01d4-8065f533652e@gmail.com> From: Suren Baghdasaryan Date: Tue, 2 Feb 2021 14:12:45 -0800 Message-ID: Subject: Re: [PATCH v3 1/1] process_madvise.2: Add process_madvise man page To: "Michael Kerrisk (man-pages)" Cc: linux-man , Andrew Morton , Jann Horn , Kees Cook , Jeffrey Vander Stoep , Minchan Kim , Michal Hocko , Shakeel Butt , David Rientjes , =?UTF-8?Q?Edgar_Arriaga_Garc=C3=ADa?= , Tim Murray , linux-mm , SElinux list , linux-security-module , Linux API , LKML , kernel-team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michael, On Tue, Feb 2, 2021 at 2:45 AM Michael Kerrisk (man-pages) wrote: > > Hello Suren (and Minchan and Michal) > > Thank you for the revisions! > > I've applied this patch, and done a few light edits. Thanks! > > However, I have a questions about undocumented pieces in *madvise(2)*, > as well as one other question. See below. > > On 2/2/21 6:30 AM, Suren Baghdasaryan wrote: > > Initial version of process_madvise(2) manual page. Initial text was > > extracted from [1], amended after fix [2] and more details added using > > man pages of madvise(2) and process_vm_read(2) as examples. It also > > includes the changes to required permission proposed in [3]. > > > > [1] https://lore.kernel.org/patchwork/patch/1297933/ > > [2] https://lkml.org/lkml/2020/12/8/1282 > > [3] https://patchwork.kernel.org/project/selinux/patch/20210111170622.2613577-1-surenb@google.com/#23888311 > > > > Signed-off-by: Suren Baghdasaryan > > Reviewed-by: Michal Hocko > > --- > > changes in v2: > > - Changed description of MADV_COLD per Michal Hocko's suggestion > > - Applied fixes suggested by Michael Kerrisk > > changes in v3: > > - Added Michal's Reviewed-by > > - Applied additional fixes suggested by Michael Kerrisk > > > > NAME > > process_madvise - give advice about use of memory to a process > > > > SYNOPSIS > > #include > > > > ssize_t process_madvise(int pidfd, > > const struct iovec *iovec, > > unsigned long vlen, > > int advice, > > unsigned int flags); > > > > DESCRIPTION > > The process_madvise() system call is used to give advice or directions > > to the kernel about the address ranges of another process or the calling > > process. It provides the advice to the address ranges described by iovec > > and vlen. The goal of such advice is to improve system or application > > performance. > > > > The pidfd argument is a PID file descriptor (see pidfd_open(2)) that > > specifies the process to which the advice is to be applied. > > > > The pointer iovec points to an array of iovec structures, defined in > > as: > > > > struct iovec { > > void *iov_base; /* Starting address */ > > size_t iov_len; /* Number of bytes to transfer */ > > }; > > > > The iovec structure describes address ranges beginning at iov_base address > > and with the size of iov_len bytes. > > > > The vlen represents the number of elements in the iovec structure. > > > > The advice argument is one of the values listed below. > > > > Linux-specific advice values > > The following Linux-specific advice values have no counterparts in the > > POSIX-specified posix_madvise(3), and may or may not have counterparts > > in the madvise(2) interface available on other implementations. > > > > MADV_COLD (since Linux 5.4.1) > > I just noticed these version numbers now, and thought: they can't be > right (because the system call appeared only in v5.11). So I removed > them. But, of course in another sense the version numbers are (nearly) > right, since these advice values were added for madvise(2) in Linux 5.4. > However, they are not documented in the madvise(2) manual page. Is it > correct to assume that MADV_COLD and MADV_PAGEOUT have exactly the same > meaning in madvise(2) (but just for the calling process, of course)? Correct. They should be added in the madvise(2) man page as well IMHO. > > > Deactive a given range of pages which will make them a more probable > > I changed: s/Deactive/Deactivate/ thanks! > > > reclaim target should there be a memory pressure. This is a > > nondestructive operation. The advice might be ignored for some pages > > in the range when it is not applicable. > > > > MADV_PAGEOUT (since Linux 5.4.1) > > Reclaim a given range of pages. This is done to free up memory occupied > > by these pages. If a page is anonymous it will be swapped out. If a > > page is file-backed and dirty it will be written back to the backing > > storage. The advice might be ignored for some pages in the range when > > it is not applicable. > > [...] > > > The hint might be applied to a part of iovec if one of its elements points > > to an invalid memory region in the remote process. No further elements will > > be processed beyond that point. > > Is the above scenario the one that leads to the partial advice case described in > RETURN VALUE? If yes, perhaps I should add some words to make that clearer. Correct. This describes the case when partial advice happens. > > You can see the light edits that I made in > https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=e3ce016472a1b3ec5dffdeb23c98b9fef618a97b > and following that I restructured DESCRIPTION a little in > https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=3aac0708a9acee5283e091461de6a8410bc921a6 The edits LGTM. Thanks, Suren. > > Thanks, > > Michael > > > -- > Michael Kerrisk > Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ > Linux/UNIX System Programming Training: http://man7.org/training/