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=-7.0 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 70CD3C433DB for ; Thu, 18 Feb 2021 07:55:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B72F660235 for ; Thu, 18 Feb 2021 07:55:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B72F660235 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 19D166B0006; Thu, 18 Feb 2021 02:55:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 14F9D6B006C; Thu, 18 Feb 2021 02:55:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA4E36B006E; Thu, 18 Feb 2021 02:55:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0038.hostedemail.com [216.40.44.38]) by kanga.kvack.org (Postfix) with ESMTP id D1ACC6B0006 for ; Thu, 18 Feb 2021 02:55:37 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9457B1DE4 for ; Thu, 18 Feb 2021 07:55:37 +0000 (UTC) X-FDA: 77830629114.19.wall50_1d0045f27653 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 6A0F31ACEBC for ; Thu, 18 Feb 2021 07:55:37 +0000 (UTC) X-HE-Tag: wall50_1d0045f27653 X-Filterd-Recvd-Size: 8773 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Thu, 18 Feb 2021 07:55:36 +0000 (UTC) Received: by mail-wm1-f53.google.com with SMTP id x4so2112255wmi.3 for ; Wed, 17 Feb 2021 23:55:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=cc:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=8VuOr5IRYyD3SOn+5chtalvwQdWPMiTxF9JpEV7axuU=; b=DiTZz/4gmJZPeTC5pv54B/6ep6c4fIy5ngNCoDUIRkkmLho2VvinhJ1mkzcRljbaKw 4CJD0yTXHFFSnmhiyBYE4ydfNjhRNJHQ7mYNnqhSS4DeCt4/9PaUd6u48IsL5Qz6nf6p oMrgW9xB+Beq4LiN/xmy0zmV9bThfFonj9oyYnhz1l3I6zmyitlpj6ICdRhN45uMJceG ZvyAVZh9LRLDdbBcH3Bxtk0I3pVm76joUGkkd+A/fglhVxxMtSX5FgisfOVSdQEfXn3Z KOySjv69SsVPdtmtkvy1STkomL3q3xgkqmu9JXTlujoSfZLAH7l9BUcwEH7mjpWdIHVS LN5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:cc:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=8VuOr5IRYyD3SOn+5chtalvwQdWPMiTxF9JpEV7axuU=; b=i+J72TcXepTAj7qwjGICU+WTBCFyZ7ZDdJlrbHAGOfI8vCVWNK0DcSSO+5tajs82zb wJh7sT/cvGt/IerHzCO2bqjFVjCE13/qMD8B3IWRDuAmG8czH8vpjxAyS96MHyvRfhK7 6AhOFbrUKBKDU8bXwTccPF4Tu2LSG41YdBf3OCaJ5asndW1jIN6kkg7/MczlsFdiutxJ shGDqMdrQwcJ3rctER7Mdz/fhdE7pGk9Ay8fHX2ZhIAX1AcIrppx+i59fALJaEKyiTq4 c1gBoiN8MmD/LmJRr+UOyM4JZSooYX3+e5lM5VQpzQb5Q3XS/Q2n6JOMW8E6A7FbHdZf Hebg== X-Gm-Message-State: AOAM530ynS1fy1fJFJc+g5XLqBHim5gKvA2WrfZmRTMgN0R9tSBnRFlw DGR7Q4jEj8pB/8/qVzYcaIw= X-Google-Smtp-Source: ABdhPJzB2TIsvhv0bBBak6Op7cXkJ1RH2wz0nb5/aO3RSIANbztDN+kcjVRGxzqpkXPSK0o0IJh9YA== X-Received: by 2002:a7b:c2a9:: with SMTP id c9mr2443813wmk.116.1613634935639; Wed, 17 Feb 2021 23:55:35 -0800 (PST) Received: from ?IPv6:2001:a61:3a2d:1d01:99ab:4f20:ed7f:402b? ([2001:a61:3a2d:1d01:99ab:4f20:ed7f:402b]) by smtp.gmail.com with ESMTPSA id t9sm7401393wrw.76.2021.02.17.23.55.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Feb 2021 23:55:35 -0800 (PST) Cc: mtk.manpages@gmail.com, 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 Subject: Re: [PATCH v3 1/1] process_madvise.2: Add process_madvise man page To: Suren Baghdasaryan References: <20210202053046.1653012-1-surenb@google.com> <079db245-a08c-0dbd-01d4-8065f533652e@gmail.com> <2d303517-cdcd-9ec8-e57d-3d065edb573c@gmail.com> From: "Michael Kerrisk (man-pages)" Message-ID: <7fb20d93-92d0-14b3-f7f9-8b9af4ebb584@gmail.com> Date: Thu, 18 Feb 2021 08:55:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US 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: 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. 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 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) --=20 Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/