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=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=ham 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 4BE8AC433DB for ; Thu, 18 Feb 2021 18:20:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A9C5A64EB3 for ; Thu, 18 Feb 2021 18:20:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9C5A64EB3 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F0A586B0006; Thu, 18 Feb 2021 13:20:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E94DE6B006C; Thu, 18 Feb 2021 13:20:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE72D6B006E; Thu, 18 Feb 2021 13:20:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id B22C36B0006 for ; Thu, 18 Feb 2021 13:20:44 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7A6D2180ACEE9 for ; Thu, 18 Feb 2021 18:20:44 +0000 (UTC) X-FDA: 77832204408.28.boy03_0b00c8b27657 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 554C76D68 for ; Thu, 18 Feb 2021 18:20:44 +0000 (UTC) X-HE-Tag: boy03_0b00c8b27657 X-Filterd-Recvd-Size: 8764 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Thu, 18 Feb 2021 18:20:43 +0000 (UTC) Received: by mail-wr1-f47.google.com with SMTP id b3so4028041wrj.5 for ; Thu, 18 Feb 2021 10:20:43 -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:content-transfer-encoding; bh=A6JvujsO2Df0YCGBHxHBzGTn/K+aJ9sF4URnvS2DhpE=; b=PdfBdSipNfU5cOPT5ougmEeo1+CgHeQo5k4LU11qUA75lMd1w6OVTj8jJ35bSIgRjS EMd5rFVvXZiggdJW8H+Wl8zQtqf+9sRr+g1Vf8b7CpIMTW8d1cehZKK4q8vcDen9wlEI bqdwgI3tBZ9gFMBkPkLMtJ5nGzKss0j+GGyaOuXBZiaoD3iLWdFC28cHR/0gamPSICv/ d3AYYIWpahamNxP+PDQVxHmZRkbDK2Qu3eMPrmHz4qNPQ6Re0FzknP3g8IHuxNkUbgF8 uA+tgiA8NeNwQVMQ98t6CBAuh2ri7ALC9Un3EZ609BRhXPPN2b45p48itrnlUsRt1z41 AG4Q== 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:content-transfer-encoding; bh=A6JvujsO2Df0YCGBHxHBzGTn/K+aJ9sF4URnvS2DhpE=; b=d7rzUHfl15vEqLM4KcC3Dt/V6IN3F5OfXr0pk928DzNhuwe9DeWFK4RZWiVx7Nykxv XkjbaEvgWyH5XktQ5QXDI579efIF6RuN3CjVHFywrM2cAGFSDkoib9vVgwkqzKLDFlF9 IMxy6st3672O9Jty8BRKG28B7qXsg1+PeJsiyRTvQM4J5HFHAoQKgg3nIta11uAJ1ZLq u1WBYJfEnf9oRDym+iYpzHle8OM1VJZnX/7e7QqCRpT0YYhNmK+xr1fcb4GQ2j1pYwvd /OMTprVBngO8xpurY150J2/KZnnZtMTFTYwsToUd6h0U45psP6t+zYouoBWwtiPAGsHS YjeA== X-Gm-Message-State: AOAM5329DXRsk28Go6WHdaj2FASUUmQm8J21sAxGSI9YEPahz9bTbtge rgo9O8pHsNol/gnR9EbKyqYQspDjlRLsOQnJXI4djQ== X-Google-Smtp-Source: ABdhPJwUro94gO/qGz4eRbhu+BIbq6W4NJ6UwoC0fGKFP2tvyoO+3SM/RLEPxTtE0knIsRq3pcxCN07LlInrrW6ZteU= X-Received: by 2002:a5d:610a:: with SMTP id v10mr5622545wrt.334.1613672442415; Thu, 18 Feb 2021 10:20:42 -0800 (PST) MIME-Version: 1.0 References: <20210202053046.1653012-1-surenb@google.com> <079db245-a08c-0dbd-01d4-8065f533652e@gmail.com> <2d303517-cdcd-9ec8-e57d-3d065edb573c@gmail.com> <7fb20d93-92d0-14b3-f7f9-8b9af4ebb584@gmail.com> In-Reply-To: <7fb20d93-92d0-14b3-f7f9-8b9af4ebb584@gmail.com> From: Suren Baghdasaryan Date: Thu, 18 Feb 2021 10:20:30 -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" Content-Transfer-Encoding: quoted-printable 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, Feb 17, 2021 at 11:55 PM Michael Kerrisk (man-pages) wrote: > > Hello Suren, > > >> Thanks. I added a few words to clarify this.> > > Any link where I can see the final version? > > Sure: > https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/man2/pro= cess_madvise.2 > > Also rendered below. Looks great. Thanks for improving it, Michael! > > Thanks, > > Michael > > NAME > process_madvise - give advice about use of memory to a process > > SYNOPSIS > #include > > ssize_t process_madvise(int pidfd, const struct iovec *iovec, > size_t vlen, int advice, > unsigned int flags); > > Note: There is no glibc wrapper for this system call; see NOTES. > > DESCRIPTION > The process_madvise() system call is used to give advice or direc= =E2=80=90 > tions to the kernel about the address ranges of another process or > of the calling process. It provides the advice for 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; /* Length of region */ > }; > > The iovec structure describes address ranges beginning at iov_base > address and with the size of iov_len bytes. > > The vlen specifies the number of elements in the iovec structure. > This value must be less than or equal to IOV_MAX (defined in its.h> or accessible via the call sysconf(_SC_IOV_MAX)). > > The advice argument is one of the following values: > > MADV_COLD > See madvise(2). > > MADV_PAGEOUT > See madvise(2). > > The flags argument is reserved for future use; currently, this ar= =E2=80=90 > gument must be specified as 0. > > The vlen and iovec arguments are checked before applying any ad= =E2=80=90 > vice. If vlen is too big, or iovec is invalid, then an error will > be returned immediately and no advice will be applied. > > The advice might be applied to only 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. (See the > discussion regarding partial advice in RETURN VALUE.) > > Permission to apply advice to another process is governed by a > ptrace access mode PTRACE_MODE_READ_REALCREDS check (see > ptrace(2)); in addition, because of the performance implications > of applying the advice, the caller must have the CAP_SYS_ADMIN ca= =E2=80=90 > pability. > > RETURN VALUE > On success, process_madvise() returns the number of bytes advised. > This return value may be less than the total number of requested > bytes, if an error occurred after some iovec elements were already > processed. The caller should check the return value to determine > whether a partial advice occurred. > > On error, -1 is returned and errno is set to indicate the error. > > ERRORS > EBADF pidfd is not a valid PID file descriptor. > > EFAULT The memory described by iovec is outside the accessible ad= =E2=80=90 > dress space of the process referred to by pidfd. > > EINVAL flags is not 0. > > EINVAL The sum of the iov_len values of iovec overflows a ssize_t > value. > > EINVAL vlen is too large. > > ENOMEM Could not allocate memory for internal copies of the iovec > structures. > > EPERM The caller does not have permission to access the address > space of the process pidfd. > > ESRCH The target process does not exist (i.e., it has terminated > and been waited on). > > VERSIONS > This system call first appeared in Linux 5.10. Support for this > system call is optional, depending on the setting of the CON= =E2=80=90 > FIG_ADVISE_SYSCALLS configuration option. > > CONFORMING TO > The process_madvise() system call is Linux-specific. > > NOTES > Glibc does not provide a wrapper for this system call; call it us= =E2=80=90 > ing syscall(2). > > SEE ALSO > madvise(2), pidfd_open(2), process_vm_readv(2), > process_vm_write(2) > > > -- > Michael Kerrisk > Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ > Linux/UNIX System Programming Training: http://man7.org/training/