Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7491198pxb; Thu, 18 Feb 2021 11:26:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRsRmUfummOL1RaIXNmi/PZ7jL2w8G4Nj4htlSXP+ASgPKaAqv4RXrYabmbs6PIXiXkbmS X-Received: by 2002:a17:906:c00a:: with SMTP id e10mr5499022ejz.501.1613676379647; Thu, 18 Feb 2021 11:26:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613676379; cv=none; d=google.com; s=arc-20160816; b=SLEkYN+HBKr12k3f/RM7BUvbvhvkinJYKdnpXYmCWLcYjmGaH08gMj8tUryn6PyqO6 hctv3zeuom8QaacMN50/zbzvXp0xszUiircqJzoWrsCr36kUdC11cX+jfwwne99moS/Y qDNQO6YHmiCrmKTjIqL9emi3pJC8SRkp2nbKfiT07V/1dqhgZumVWEUElual8Et6tK4U t/nylVxkL1vEHUblzd+i4gNUCqM7Yir9IQEU5IREXWj8qj3pmnGHVKp8JCY1sp18wVpW gVds0KAtRHO5UZDsjBP7WAiTnkx2YrDe2LtS2x/GyPibWlB5XuDCOY8zQPPbmRm9Bxiq YN1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=A6JvujsO2Df0YCGBHxHBzGTn/K+aJ9sF4URnvS2DhpE=; b=fQOaZjtm0sK+FOqX9ZADAi37N2+wepyl7g+88d3wkUi2htphLy7KxvuiZuvma4Qkqb HP9rjHIGQnJe5OKTwVBtw+Bo2VP/QRjTCdiHagHsvwLoKZZW0+3HMufJGhHAHwFTsK2m 71/6oLLYv7WTOP5oUHSzPQLivbG9GejXaJKFYIvhnWbKN6/BOtBfYnWYXXC/FTrYAZVC fvpR9d12wJ8ePZMhEa8kEpmiFavkwQGE4oBOpPu079GT0KjHL6HI6uzP6LvHt7bczqNy BixOr1yx9JZJZ3XNl8vzHQS90ck4v3GFNxqCgcVZxCR72Gcgjh67RdJdP7hOebw/Inl/ 4Neg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PdfBdSip; 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 d8si3583312ejw.416.2021.02.18.11.25.52; Thu, 18 Feb 2021 11:26:19 -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=PdfBdSip; 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 S232720AbhBRTXN (ORCPT + 99 others); Thu, 18 Feb 2021 14:23:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231597AbhBRSVZ (ORCPT ); Thu, 18 Feb 2021 13:21:25 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 093E7C061786 for ; Thu, 18 Feb 2021 10:20:44 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id n4so4059166wrx.1 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=eQjvp9pg8fJH6Y8miYDpRexcUADIxZZwucF4T5byvONzJlDXnJWjU1nMSL8tw0MYTE zAkKn8mlKVvDfWt2tm4lE42OEQxmkdF90F2RONzGiJX5lNWcLdIgxWbf6xiTlIMkAnzS /yOPvnPcOhbMSFwJLLj3IuQs4+fOy09v4lrsvrVr1sXbA3flI+rQynN4NSTFNPMu+iUT cghzUJNl3CxOhYwscYDnZ6O/Rrgjn1btUfackcCDgertUdcT1z6W7Te2wIKB6ViS0uqq 6BXpYmFLys46EFzgFeAWe4s28KrEWHXSD1XdoN7iTsjHrFAvEjdLD5lU0J1mIcegqnMB SUwQ== X-Gm-Message-State: AOAM532MfirnjRsJrV47o0TpQfvpPxRXMA42ozfGScOFGr8hiGONQjpk Ew39/QFWrN8o8j4UBTPMuKE0EhUk8J/1rTpWybhISQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/