From patchwork Thu May 16 09:42:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Natalenko X-Patchwork-Id: 10946167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 47D31912 for ; Thu, 16 May 2019 09:42:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 385532896F for ; Thu, 16 May 2019 09:42:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C1822898E; Thu, 16 May 2019 09:42:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C465828972 for ; Thu, 16 May 2019 09:42:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DFE36B0006; Thu, 16 May 2019 05:42:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 86AC06B0007; Thu, 16 May 2019 05:42:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70C096B0008; Thu, 16 May 2019 05:42:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by kanga.kvack.org (Postfix) with ESMTP id 265886B0006 for ; Thu, 16 May 2019 05:42:40 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id v5so1100768wrn.6 for ; Thu, 16 May 2019 02:42:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ec97xsumF3Pkv1YQN1NPRzLcPj4UDGH/s6YIE0YJh6Q=; b=oB1GqouR+1EXjTtNWfIxq1krXW2cbI2ng5pq5DN1/Ih7vOvWcUKvQMsUVHiOyV9kL4 BsypbQSFZFLYJYnIOtI/nF96kLLQpwc3KtIUYYbAlI2PuR16Gq8OAc1RWEKpAl6UdtnF 4XfiVST+YLVXwY2IWuLHFZER92UoWFyfir2snqnMYPLp41/jPVAB85zwq8lymFa0Zucl YPjNPm+DksX2NRqBJ0BqUW1asOi7GMpfw1zquN3BBXtGyIGvc47hMVq2Nl1LriePGF4I kmDVe06J3tHBfwj9n8DXZuFg3wWguttCMBl/pl4iRoekfIW1HAbHmu3uy5KrxWpOH9Ex qx4Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAVxvUMfxmu7Jk5DpHWBCgOofyGSoGIUyJ6xVNpOPdg0ax/5M97B 2Ey9QToTihY8BrKubOrhH4xAZU1S3SIZeaTSJcmPrvn1Gnpi7G0OyJsIfa5VgAFlDHRipn/gqAJ PpRJ2JQ1zkRgaJdekpbSOXluNWw+VjTHpx6LiquYXGs/rWtLT63PmigVz7ONEqTQ2eA== X-Received: by 2002:a5d:5506:: with SMTP id b6mr27601652wrv.221.1557999759713; Thu, 16 May 2019 02:42:39 -0700 (PDT) X-Received: by 2002:a5d:5506:: with SMTP id b6mr27601590wrv.221.1557999758670; Thu, 16 May 2019 02:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557999758; cv=none; d=google.com; s=arc-20160816; b=Npy5C9p1pvUqbLbOL5ekWBUXArxtMNWFPxxjEFy6GYupr8DMzJRJztKt0i7MJPFBmV 8tIISPa4fCLdkjtZKG9S+jojJ7SFjJOEdNK5UFwARUIKLF1jt1bRZIKnDX9GB7juzDgF XDqtI3iUOJmdF1iHRHOADnVdKi8v6yGezcIRw5Xf1xXvI7S02KLRDyVJz7mIBkzC3cse BW5ZWVpLvs3+11+SAJ8kn9PZNNbzqGS0rJo73MhzHD8xKTT6eQ3NEShhNxAFAaMqgisn 2jlHRU3H4C/ImT8cnmPJYMLP2COJQlPxj0bMB1s4lPNkHBmo56K0Q+7twTJRBl5iXFuy boZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ec97xsumF3Pkv1YQN1NPRzLcPj4UDGH/s6YIE0YJh6Q=; b=zW1bp2aqdxyJ2QkMg9mUGzCwgBZosCy/Qp3SMHYujhtrvOMcHPp6TGMLWg4rhyCh/7 MSUOGtuihHmPF6ThXB0q7ZVfzIK0v2F1f6RhwHLZEO5adq4p/SOwF8Hmj/2tcqIoY3SP /S3a+rxDvnHnwEhWzGH2GiOQ2LolTH38bVZXP2bsp+gwaMceuWYWnu4G1a5SwNEfhSFL 4cqDsddpHL30IuTcwbo9CmhYtpD6Dd7u1iKng7vBtjgmhYFZivQEBxlB4Wxq7FDmBc0U IbEm6fsw6muDo2DRlBzmUD2kzocQJz/On1It3LAx+jdkQwo6eGSr//psT1R917AiM1EY U6ZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id n16sor3871548wrx.15.2019.05.16.02.42.38 for (Google Transport Security); Thu, 16 May 2019 02:42:38 -0700 (PDT) Received-SPF: pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Google-Smtp-Source: APXvYqzL4YP+rxRXtwxz4lhwPcqqtNNojy1+KdB1FfWoc/WFzJDav/U0UgURDFche4Hrog/mqIRD1A== X-Received: by 2002:a5d:4647:: with SMTP id j7mr24112266wrs.280.1557999758291; Thu, 16 May 2019 02:42:38 -0700 (PDT) Received: from localhost (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id t18sm7663093wrg.19.2019.05.16.02.42.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 May 2019 02:42:37 -0700 (PDT) From: Oleksandr Natalenko To: linux-kernel@vger.kernel.org Cc: Kirill Tkhai , Hugh Dickins , Alexey Dobriyan , Vlastimil Babka , Michal Hocko , Matthew Wilcox , Pavel Tatashin , Greg KH , Suren Baghdasaryan , Minchan Kim , Timofey Titovets , Aaron Tomlin , Grzegorz Halat , linux-mm@kvack.org, linux-api@vger.kernel.org Subject: [PATCH RFC 1/5] proc: introduce madvise placeholder Date: Thu, 16 May 2019 11:42:30 +0200 Message-Id: <20190516094234.9116-2-oleksandr@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516094234.9116-1-oleksandr@redhat.com> References: <20190516094234.9116-1-oleksandr@redhat.com> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Add a write-only /proc//madvise file to handle remote madvise operations. For now, this is just a soother that does nothing. Signed-off-by: Oleksandr Natalenko --- fs/proc/base.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fs/proc/base.c b/fs/proc/base.c index 6a803a0b75df..f69532d6b74f 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2957,6 +2957,25 @@ static int proc_stack_depth(struct seq_file *m, struct pid_namespace *ns, } #endif /* CONFIG_STACKLEAK_METRICS */ +static ssize_t madvise_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct task_struct *task; + + task = get_proc_task(file_inode(file)); + if (!task) + return -ESRCH; + + put_task_struct(task); + + return count; +} + +static const struct file_operations proc_madvise_operations = { + .write = madvise_write, + .llseek = noop_llseek, +}; + /* * Thread groups */ @@ -3061,6 +3080,7 @@ static const struct pid_entry tgid_base_stuff[] = { #ifdef CONFIG_STACKLEAK_METRICS ONE("stack_depth", S_IRUGO, proc_stack_depth), #endif + REG("madvise", S_IRUGO|S_IWUSR, proc_madvise_operations), }; static int proc_tgid_base_readdir(struct file *file, struct dir_context *ctx) From patchwork Thu May 16 09:42:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Natalenko X-Patchwork-Id: 10946171 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D43413AD for ; Thu, 16 May 2019 09:42:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFE7C28972 for ; Thu, 16 May 2019 09:42:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E46442898D; Thu, 16 May 2019 09:42:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68DBC28972 for ; Thu, 16 May 2019 09:42:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 70B126B0007; Thu, 16 May 2019 05:42:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 66EB46B0008; Thu, 16 May 2019 05:42:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50EAA6B000A; Thu, 16 May 2019 05:42:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id 0849A6B0007 for ; Thu, 16 May 2019 05:42:42 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id r16so1099642wrj.13 for ; Thu, 16 May 2019 02:42:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=YN77z8gKHSuM2XjFecvZy0A0ECsUV7zC1Q0pr8QKOlY=; b=BVazevE4SHQIFl3lu65ZMITv0vrfIzzx4p9h9jwEeVQUdcWEyMETFYWF9/nqXdHBL1 kky2rB8DHSwqVgwz5aax0q70S2Yiu2NZyKyGgBuKzLH+vWFfpWr8bvFlIgGP2GIjusgO 5GLbaMeBww7b3V1sdY7S8h/J5T1blWksBi/wHfdEBSL+vzsvtcXhtmTy2D0UtCbGE+iQ 9KeP2PWjz1RlvOAQpRLUMY1qclU6rfT2PdSLeDENRUzY79YRVM/wbCfmD+zZmAylFRYW z7Q0zqIm2YLerc+NKkTe4xa+Gfyisa28sagwJzREhEthxCwLW7je5uXOx+8IKuyyGOWB ftaA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAXAbqiqSjkuuE/1kEbjlr99G/oWibf5qkESJXBkdCihHKBPKjJw 5D/C/xT+y0ItfDRgAZzvWjfVEHI9AXrk/49XMHnWpAWw0IPdLgjDp43EOMR4oMLQvOqsSwD/4Q5 5rVcciHuyiEVXiyJIuVQibnMJHcddT32gO7vmVLjPCQoSFtr1aoO8/iRtwvLr83TPhA== X-Received: by 2002:a1c:48d7:: with SMTP id v206mr27766233wma.38.1557999761556; Thu, 16 May 2019 02:42:41 -0700 (PDT) X-Received: by 2002:a1c:48d7:: with SMTP id v206mr27766162wma.38.1557999760355; Thu, 16 May 2019 02:42:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557999760; cv=none; d=google.com; s=arc-20160816; b=AOmjQOPdO6AuGyTYqnxGhzdGTyTX8pKqL1FSCEMv2PqBz/GtlPnDCxdV66MWnpBTZh VciLAEOU5pHqxal+KO6KObZq4Z5PYCI/QWbVnQTIz5YxDumII1dCZf3+cf6zejs38dXB dN8Gy9y01hNmpqfBdEplv+9NYvGbyaFKvsNmmXMUeeU+mi5YFjn8eGX4BjUT3GpDCQQ3 /5WlQaTweoqfpbwUxqBJYhye+pW+IwR1sS6EqVt/z6qXl8Rjg8ybxtyCVIVI5SHBiIYG boh/r5q+NKp9tyoWxyf0Z264xYGSvnmKyQ6mpQIm3OTEOOc19Bjn4zQ+UB5Rt8PYsHgi 4KNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=YN77z8gKHSuM2XjFecvZy0A0ECsUV7zC1Q0pr8QKOlY=; b=Qc6EzPcNGjVyaSe7dcINvu50kAp57V/H6VzIEJUxePP/B4Ujmzd0wJWUIL7v8rVked ZeAZJ+11Rfmr0mtHO6rKFMx+5Jw5tC8OzLZlb/+rZqiwCf1x6EoywbT9V1c8j2/HTEmj lHbp3OFutC7Hy4RyVD+/xl6LtdkMel3R7VVBoEf0J8mYWQFRDXl2DwxBdyG+UFKeUrtA PqMJOcxJceXdkeKjjLwrBNQ9ZCdYggrlnlSWIirRv2FgMsKFWvEOMBC35lpRwtsLDj9i RMgZG0wTRWjloURRhaIzBNVUUNC3oBjTE/Kprmf58YzilZT4q0TcQSLmeWCpzVV1x82y PLPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p6sor3820464wrt.23.2019.05.16.02.42.40 for (Google Transport Security); Thu, 16 May 2019 02:42:40 -0700 (PDT) Received-SPF: pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Google-Smtp-Source: APXvYqys469LpVWfYxPlfxZW3I0nW/iuorQWcrS5tP7pLu+XZ/hJioroCE9kOeMmFNuO1N+8Ds8oZA== X-Received: by 2002:adf:f9c3:: with SMTP id w3mr20196436wrr.271.1557999759998; Thu, 16 May 2019 02:42:39 -0700 (PDT) Received: from localhost (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id s3sm7204729wre.97.2019.05.16.02.42.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 May 2019 02:42:39 -0700 (PDT) From: Oleksandr Natalenko To: linux-kernel@vger.kernel.org Cc: Kirill Tkhai , Hugh Dickins , Alexey Dobriyan , Vlastimil Babka , Michal Hocko , Matthew Wilcox , Pavel Tatashin , Greg KH , Suren Baghdasaryan , Minchan Kim , Timofey Titovets , Aaron Tomlin , Grzegorz Halat , linux-mm@kvack.org, linux-api@vger.kernel.org Subject: [PATCH RFC 2/5] mm/ksm: introduce ksm_madvise_merge() helper Date: Thu, 16 May 2019 11:42:31 +0200 Message-Id: <20190516094234.9116-3-oleksandr@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516094234.9116-1-oleksandr@redhat.com> References: <20190516094234.9116-1-oleksandr@redhat.com> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Move MADV_MERGEABLE part of ksm_madvise() into a dedicated helper since it will be further used for marking VMAs to be merged forcibly. This does not bring any functional changes. Signed-off-by: Oleksandr Natalenko --- include/linux/ksm.h | 2 ++ mm/ksm.c | 60 +++++++++++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/include/linux/ksm.h b/include/linux/ksm.h index e48b1e453ff5..e824b3141677 100644 --- a/include/linux/ksm.h +++ b/include/linux/ksm.h @@ -19,6 +19,8 @@ struct stable_node; struct mem_cgroup; #ifdef CONFIG_KSM +int ksm_madvise_merge(struct mm_struct *mm, struct vm_area_struct *vma, + unsigned long *vm_flags); int ksm_madvise(struct vm_area_struct *vma, unsigned long start, unsigned long end, int advice, unsigned long *vm_flags); int __ksm_enter(struct mm_struct *mm); diff --git a/mm/ksm.c b/mm/ksm.c index fc64874dc6f4..1fdcf2fbd58d 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -2442,41 +2442,53 @@ static int ksm_scan_thread(void *nothing) return 0; } -int ksm_madvise(struct vm_area_struct *vma, unsigned long start, - unsigned long end, int advice, unsigned long *vm_flags) +int ksm_madvise_merge(struct mm_struct *mm, struct vm_area_struct *vma, + unsigned long *vm_flags) { - struct mm_struct *mm = vma->vm_mm; int err; - switch (advice) { - case MADV_MERGEABLE: - /* - * Be somewhat over-protective for now! - */ - if (*vm_flags & (VM_MERGEABLE | VM_SHARED | VM_MAYSHARE | - VM_PFNMAP | VM_IO | VM_DONTEXPAND | - VM_HUGETLB | VM_MIXEDMAP)) - return 0; /* just ignore the advice */ + /* + * Be somewhat over-protective for now! + */ + if (*vm_flags & (VM_MERGEABLE | VM_SHARED | VM_MAYSHARE | + VM_PFNMAP | VM_IO | VM_DONTEXPAND | + VM_HUGETLB | VM_MIXEDMAP)) + return 0; /* just ignore the advice */ - if (vma_is_dax(vma)) - return 0; + if (vma_is_dax(vma)) + return 0; #ifdef VM_SAO - if (*vm_flags & VM_SAO) - return 0; + if (*vm_flags & VM_SAO) + return 0; #endif #ifdef VM_SPARC_ADI - if (*vm_flags & VM_SPARC_ADI) - return 0; + if (*vm_flags & VM_SPARC_ADI) + return 0; #endif - if (!test_bit(MMF_VM_MERGEABLE, &mm->flags)) { - err = __ksm_enter(mm); - if (err) - return err; - } + if (!test_bit(MMF_VM_MERGEABLE, &mm->flags)) { + err = __ksm_enter(mm); + if (err) + return err; + } + + *vm_flags |= VM_MERGEABLE; + + return 0; +} - *vm_flags |= VM_MERGEABLE; +int ksm_madvise(struct vm_area_struct *vma, unsigned long start, + unsigned long end, int advice, unsigned long *vm_flags) +{ + struct mm_struct *mm = vma->vm_mm; + int err; + + switch (advice) { + case MADV_MERGEABLE: + err = ksm_madvise_merge(mm, vma, vm_flags); + if (err) + return err; break; case MADV_UNMERGEABLE: From patchwork Thu May 16 09:42:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Natalenko X-Patchwork-Id: 10946173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CE5413AD for ; Thu, 16 May 2019 09:42:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DEDF2896F for ; Thu, 16 May 2019 09:42:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82635289B8; Thu, 16 May 2019 09:42:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 037E5289D4 for ; Thu, 16 May 2019 09:42:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A0486B0008; Thu, 16 May 2019 05:42:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 18E166B000A; Thu, 16 May 2019 05:42:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02E026B000C; Thu, 16 May 2019 05:42:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by kanga.kvack.org (Postfix) with ESMTP id A977D6B0008 for ; Thu, 16 May 2019 05:42:43 -0400 (EDT) Received: by mail-wm1-f71.google.com with SMTP id w9so571478wmc.5 for ; Thu, 16 May 2019 02:42:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QVnbcHKCSN58gborHO3ol7EK02u5KFHxun0EUOWl0vk=; b=Bz/BLjN0xQ9WFK7e5cH0tUG/xJBdFdiZgWWgWGOY/nv57ZC7XiLAi1vjpW08l3vTYj 4kt3o72Z1vlpphjRcAmiIBJhIzdhzysXSxoUc0tQ6W4h6qOKnN0HNpdSbInxl1b7rlVZ BLVbVVD80rfrmcN1Z8F/gtybSGD9vIoUxArR+43JH0nB9LYHre9jy4CGc8E6n5eKu2D7 GdTLrTGm02AotxKERfzQBqAkfedkkDEOn+Vn4XtIQrgOAg6CheTTgokGvAdvCr6oqihB Z1pZmue53DwwpezBCll+pc/0o9RxnYJucnHZyoI4x5bn5O5porZTAJ/hxJ53eZpwJN1k /rCQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAWi33PMSrjXCe+lpvq8pndpGB6RlTTqls308SvXyRhvQLHvBetL W1c7MjbBIkDIIY61v0gSey4qIPrKBnIkUl3XvvXgQzJnbnpVbkuzvqAvqyq2r+Udr+q8F4kLqNV 0XB77HUz97Y8oNrrlR8e7ZF7IApV2/0VAIvfUkLN5J1jpDdkUnuPBeLaN4T51hqEsFA== X-Received: by 2002:a1c:6586:: with SMTP id z128mr11441203wmb.67.1557999763221; Thu, 16 May 2019 02:42:43 -0700 (PDT) X-Received: by 2002:a1c:6586:: with SMTP id z128mr11441136wmb.67.1557999762047; Thu, 16 May 2019 02:42:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557999762; cv=none; d=google.com; s=arc-20160816; b=MW05nh/00nuPcYLDsou7bjzvgojnEjkrcwARubgX641ynjYo7X4jl3Fc5c/97eqOyW BClABGFvn9oKpix4j4Iv/ixK7uxN1WbqSCUJxkuf5L1ttdcJ4L0HsjGTk4zRxIvEaSGG S6XQuMWigBw/IND/pGyimueeBs6EKNxQrresgH+TPIyQoLpeQcNA8cdue/MYRapI6LsM jl2cSwAgZHf82/amkpF94MkllJDq04QDBajVUqHH9lrYjp5r8HdEPd03MAYaBMGQWtYY LhTd5KqQWSOeewckSd9yZ4YSOzVoMhNNBkRU4E8RGBKuoEUsPDCn8SD7FJDTejD8y9no pKpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=QVnbcHKCSN58gborHO3ol7EK02u5KFHxun0EUOWl0vk=; b=UvnnCLyJfUsGdrbyZCnqbDYsXpioJBskBIFu2S5nYPj7iZ2dNFbROo0B9qrKo/fEau Whc9I6I5qUhQdlEPUogtmLf41UHcWEFZKTmvfcnX7RsM9ZoN5tyNeIEqL78FcMRzXk3l kZC5ZWAXjBefJUQhAdpqY1aRfsffFnGMv9viIQN05JPmnRzcif7uDkV7m/HU3Vd9RrLa zyrchkSNaoHlbHESpmO7BkLdfTNvlivDXqdcp+fjsIJnDdChpBMySpZyfNN0jPELE3V9 +OCxbF/bpgyE7lfPgf0R52T5Txnh6v4NbLiPBK6Hf3sWs+ANZ1WZ5zWr9TGn4AZ99wRl N3jw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x9sor3862542wrw.47.2019.05.16.02.42.41 for (Google Transport Security); Thu, 16 May 2019 02:42:42 -0700 (PDT) Received-SPF: pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Google-Smtp-Source: APXvYqwl58jVVB/evRftpSSgIkEdQu3pDWBXBnUiYvoeLvTMFHBb+KM6NeJY7cXdaHqSSVbMh3vTNg== X-Received: by 2002:a5d:6982:: with SMTP id g2mr13708219wru.223.1557999761707; Thu, 16 May 2019 02:42:41 -0700 (PDT) Received: from localhost (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id n63sm4614805wmn.38.2019.05.16.02.42.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 May 2019 02:42:40 -0700 (PDT) From: Oleksandr Natalenko To: linux-kernel@vger.kernel.org Cc: Kirill Tkhai , Hugh Dickins , Alexey Dobriyan , Vlastimil Babka , Michal Hocko , Matthew Wilcox , Pavel Tatashin , Greg KH , Suren Baghdasaryan , Minchan Kim , Timofey Titovets , Aaron Tomlin , Grzegorz Halat , linux-mm@kvack.org, linux-api@vger.kernel.org Subject: [PATCH RFC 3/5] mm/ksm: introduce ksm_madvise_unmerge() helper Date: Thu, 16 May 2019 11:42:32 +0200 Message-Id: <20190516094234.9116-4-oleksandr@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516094234.9116-1-oleksandr@redhat.com> References: <20190516094234.9116-1-oleksandr@redhat.com> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Move MADV_UNMERGEABLE part of ksm_madvise() into a dedicated helper since it will be further used for unmerging VMAs forcibly. This does not bring any functional changes. Signed-off-by: Oleksandr Natalenko --- include/linux/ksm.h | 2 ++ mm/ksm.c | 32 ++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/include/linux/ksm.h b/include/linux/ksm.h index e824b3141677..a91a7cfc87a1 100644 --- a/include/linux/ksm.h +++ b/include/linux/ksm.h @@ -21,6 +21,8 @@ struct mem_cgroup; #ifdef CONFIG_KSM int ksm_madvise_merge(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long *vm_flags); +int ksm_madvise_unmerge(struct vm_area_struct *vma, unsigned long start, + unsigned long end, unsigned long *vm_flags); int ksm_madvise(struct vm_area_struct *vma, unsigned long start, unsigned long end, int advice, unsigned long *vm_flags); int __ksm_enter(struct mm_struct *mm); diff --git a/mm/ksm.c b/mm/ksm.c index 1fdcf2fbd58d..e0357e25e09f 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -2478,6 +2478,25 @@ int ksm_madvise_merge(struct mm_struct *mm, struct vm_area_struct *vma, return 0; } +int ksm_madvise_unmerge(struct vm_area_struct *vma, unsigned long start, + unsigned long end, unsigned long *vm_flags) +{ + int err; + + if (!(*vm_flags & VM_MERGEABLE)) + return 0; /* just ignore the advice */ + + if (vma->anon_vma) { + err = unmerge_ksm_pages(vma, start, end); + if (err) + return err; + } + + *vm_flags &= ~VM_MERGEABLE; + + return 0; +} + int ksm_madvise(struct vm_area_struct *vma, unsigned long start, unsigned long end, int advice, unsigned long *vm_flags) { @@ -2492,16 +2511,9 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start, break; case MADV_UNMERGEABLE: - if (!(*vm_flags & VM_MERGEABLE)) - return 0; /* just ignore the advice */ - - if (vma->anon_vma) { - err = unmerge_ksm_pages(vma, start, end); - if (err) - return err; - } - - *vm_flags &= ~VM_MERGEABLE; + err = ksm_madvise_unmerge(vma, start, end, vm_flags); + if (err) + return err; break; } From patchwork Thu May 16 09:42:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Natalenko X-Patchwork-Id: 10946175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7FF05912 for ; Thu, 16 May 2019 09:42:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FC682896F for ; Thu, 16 May 2019 09:42:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63CDC289B8; Thu, 16 May 2019 09:42:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC9962896F for ; Thu, 16 May 2019 09:42:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07D946B000A; Thu, 16 May 2019 05:42:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F232B6B000C; Thu, 16 May 2019 05:42:45 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D9A556B000D; Thu, 16 May 2019 05:42:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by kanga.kvack.org (Postfix) with ESMTP id 8CD626B000A for ; Thu, 16 May 2019 05:42:45 -0400 (EDT) Received: by mail-wm1-f69.google.com with SMTP id u124so573832wmg.1 for ; Thu, 16 May 2019 02:42:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZZGnY1AeO4vEIRNllzlClW+UmlSDLeAarYqLIOTY4ZI=; b=tAme9xoqakKQsO1U8b6VwZGq5TD8zvz4Ij97dS8SKHZagz2nX9iMb346hys/iK8bwD v+PfkIcJ/PVwOrQHvemDsN/UgDTkV+AoGEzLwyUT/dxeEAoIp0RE/J4loZ5R717pNSip F3AdClfZYC74Tba0t5jjUTjtjoXaWfV1eyErRrnqBLU8EcetvTe2f6km+GA261WBGat5 e75s9hDj7KO+Nx4rV5AK2CgRC/JfM0csnjMT2m3D5xn5pO6PUJ9ybZ5iyJIsBK+SxATB /k3kYrYcfEb1nNj4s4W/f5ffv2Mhmk1dtxINkfN2BcXfOOY/Pbj4rGND6/HFcR55kDMT 8Qgw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAWy0YZD2dGzAK13gWFXDW8/qndZj8IjwiV4NE3AlGqgcgxq7iIf 6VV5C/i0v17uQedz7pU7BXWFNBKtHqo+1eVGIWBIH4Ktpi4A+TLgz85ja5+Cyr6FbkYI6QSkfQz 2e76H3WmI/8bVshHfG2CEncq7wSSp7zid33XTqSr4tje2w76C8dKqPMQX5sOKhLuVbA== X-Received: by 2002:a1c:1902:: with SMTP id 2mr25859559wmz.153.1557999764980; Thu, 16 May 2019 02:42:44 -0700 (PDT) X-Received: by 2002:a1c:1902:: with SMTP id 2mr25859473wmz.153.1557999763561; Thu, 16 May 2019 02:42:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557999763; cv=none; d=google.com; s=arc-20160816; b=afD/KYhXQQHNPwbfkSa8XSPZbIctjt9WzY9jSFfMtRFKC2YUGmUypW90dLhx76JZby IgbjaR4+HfrVCQoHO7Y3VGnuOzVr8cjm/IMx0j67izSwSTLzkrcw6uBfqwjV2HiJvxj1 6GhyS4vXfN/8OUGXBgOa6O5wBirw0dyTTDjR3PT984mpNoHsVscOli28Vqfj1nMMH8uG 9NEZLR36PgKEcIqY9x6vETlZrLGrpegkL+ShFmrmlJ3L4XSE9OmlnI5qK9p879BWq6LA tnIVlv20TFWMMqGpz0Ermk6fXYpmtIrIVSXvuy5QGv4QWJZ5ngxRRdr6/ljxLQ9sA0Jb Hq8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ZZGnY1AeO4vEIRNllzlClW+UmlSDLeAarYqLIOTY4ZI=; b=bMGpJc5CxIW1ag0BBJBZVPAgpdsYeDuNYn+HPtHbNOGbRcPXQw1RMh1jOO+XGMLfeT AG3daLTX/2EO1iubfFnzchAI6OocnVPeH2DFRLrvEi8j5jUcvlsiObK+tzPVA55ubO/S k43ry00agGqpTquCZRRNfygs7khc5H1Dl2WUMQjCJ+LrGBF6Nh7bKbtSt28EEu4+Iua3 ZAnS7UGTF6vgx2HrlTiB6NqPvha8emSq6KqHXErG8kHCnRcImSjZpy6PNdEsF6/dp+XV 8sC8ht4iQ6wRDl/9URvnoE5ewfGQAHNDfFWbURGLCRrYAd+aw8YchlRZSf8d0s0o6vAE qFAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id h76sor2885791wme.12.2019.05.16.02.42.43 for (Google Transport Security); Thu, 16 May 2019 02:42:43 -0700 (PDT) Received-SPF: pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Google-Smtp-Source: APXvYqzGCZsfZTLnp32ZXX+p/N913HP7wOvaTxVvqZVz8kRuhkb2Lox0z5g/+tp8DehjQ+5iLc3ZLg== X-Received: by 2002:a7b:c8d1:: with SMTP id f17mr14149157wml.45.1557999763188; Thu, 16 May 2019 02:42:43 -0700 (PDT) Received: from localhost (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id s18sm4074000wmc.41.2019.05.16.02.42.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 May 2019 02:42:42 -0700 (PDT) From: Oleksandr Natalenko To: linux-kernel@vger.kernel.org Cc: Kirill Tkhai , Hugh Dickins , Alexey Dobriyan , Vlastimil Babka , Michal Hocko , Matthew Wilcox , Pavel Tatashin , Greg KH , Suren Baghdasaryan , Minchan Kim , Timofey Titovets , Aaron Tomlin , Grzegorz Halat , linux-mm@kvack.org, linux-api@vger.kernel.org Subject: [PATCH RFC 4/5] mm/ksm, proc: introduce remote merge Date: Thu, 16 May 2019 11:42:33 +0200 Message-Id: <20190516094234.9116-5-oleksandr@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516094234.9116-1-oleksandr@redhat.com> References: <20190516094234.9116-1-oleksandr@redhat.com> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Use previously introduced remote madvise knob to mark task's anonymous memory as mergeable. To force merging task's VMAs, "merge" hint is used: # echo merge > /proc//madvise Force unmerging is done similarly: # echo unmerge > /proc//madvise To achieve this, previously introduced ksm_madvise_*() helpers are used. Signed-off-by: Oleksandr Natalenko --- fs/proc/base.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index f69532d6b74f..6677580080ed 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -94,6 +94,8 @@ #include #include #include +#include +#include #include #include "internal.h" #include "fd.h" @@ -2960,15 +2962,63 @@ static int proc_stack_depth(struct seq_file *m, struct pid_namespace *ns, static ssize_t madvise_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { + /* For now, only KSM hints are implemented */ +#ifdef CONFIG_KSM + char buffer[PROC_NUMBUF]; + int behaviour; struct task_struct *task; + struct mm_struct *mm; + int err = 0; + struct vm_area_struct *vma; + + memset(buffer, 0, sizeof(buffer)); + if (count > sizeof(buffer) - 1) + count = sizeof(buffer) - 1; + if (copy_from_user(buffer, buf, count)) + return -EFAULT; + + if (!memcmp("merge", buffer, min(sizeof("merge")-1, count))) + behaviour = MADV_MERGEABLE; + else if (!memcmp("unmerge", buffer, min(sizeof("unmerge")-1, count))) + behaviour = MADV_UNMERGEABLE; + else + return -EINVAL; task = get_proc_task(file_inode(file)); if (!task) return -ESRCH; + mm = get_task_mm(task); + if (!mm) { + err = -EINVAL; + goto out_put_task_struct; + } + + down_write(&mm->mmap_sem); + switch (behaviour) { + case MADV_MERGEABLE: + case MADV_UNMERGEABLE: + vma = mm->mmap; + while (vma) { + if (behaviour == MADV_MERGEABLE) + ksm_madvise_merge(vma->vm_mm, vma, &vma->vm_flags); + else + ksm_madvise_unmerge(vma, vma->vm_start, vma->vm_end, &vma->vm_flags); + vma = vma->vm_next; + } + break; + } + up_write(&mm->mmap_sem); + + mmput(mm); + +out_put_task_struct: put_task_struct(task); - return count; + return err ? err : count; +#else + return -EINVAL; +#endif /* CONFIG_KSM */ } static const struct file_operations proc_madvise_operations = { From patchwork Thu May 16 09:42:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Natalenko X-Patchwork-Id: 10946179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC629912 for ; Thu, 16 May 2019 09:42:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCB4428972 for ; Thu, 16 May 2019 09:42:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B066628985; Thu, 16 May 2019 09:42:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 525E32898D for ; Thu, 16 May 2019 09:42:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3FDE76B000C; Thu, 16 May 2019 05:42:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3B1FF6B000D; Thu, 16 May 2019 05:42:47 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D11C6B000E; Thu, 16 May 2019 05:42:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by kanga.kvack.org (Postfix) with ESMTP id B4F9E6B000C for ; Thu, 16 May 2019 05:42:46 -0400 (EDT) Received: by mail-wm1-f71.google.com with SMTP id h8so819944wmf.1 for ; Thu, 16 May 2019 02:42:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=I6Qf9WePQnjM1qP5GnvXQ6iGQgDn7ErWaVxKlruplAs=; b=pvBoNHr6WvUqgJZwi29PNhnVcWn02DDkH0NfGbieeinKz2/dXF/lcPZta1hM9lTWfP dI6KCzoaLegqTrBYpOKAwkZcd7grgaB5UUyiCxBE4UllN4de0PSIMuPy0twlz9f8K7m2 vabUbzZqvo3RDRMl8pnesDVl3RZUEGaEI3VJjbW31JMyqVo/vlP4WBTWB3x8PJKMw/Ee UdRwDEon5Ybl00Zl1/xUwMotr0wAvFPw11VLEwO82QZOWR1s4Uw1tTL7FwS84v5DV3To nGs0R3O6zFI8ewmBLtQpEJPNZve820qheSLtASWbY0aarMRsvnxBmGcoHjYKDorUfBvn 073w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAVrCDCBjGw3BrF0JSa4ON89UDMhqJqkM+0KEk2i0Wn6eB0ju9hl zNT7QfODtYfhCt6ypfHjWhqDDqE7W1cek/7fsK7xz6MAr3rWXlegQkQsLl0j13lz3qahvrAjTC2 sLD+A5yvb7FAkcaMsIF/6MCY5/C5Ycpxx+fRTonZUkY/EsIh7+Kj5b+PlRPDCcx/Glg== X-Received: by 2002:a1c:e144:: with SMTP id y65mr26100826wmg.147.1557999766268; Thu, 16 May 2019 02:42:46 -0700 (PDT) X-Received: by 2002:a1c:e144:: with SMTP id y65mr26100775wmg.147.1557999765221; Thu, 16 May 2019 02:42:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557999765; cv=none; d=google.com; s=arc-20160816; b=tACdX6GLPmwDzOHGMennKf9w9g8QXEfvmV3xJ7by8MlmAV8IrnMsEXeJ8fd78or27K ZUgXoY4woSg8k7wOBOd0CREO0YpCU4DvBNo5DWTEi6yGxUgZZWMzrTImTdwCmQhg2FZV IiCGitbi6RpEP9LK80NFp/JVVrySMdms6T10V2lTSrusxtpdNk+e0tVY7pxPWedHYBnM ekXwVvkK5ki/EZ/0wElox9vYKOj0dqiF/L3CCO2gRcRZTPotdeh8lwwMekUpn3tRNRuE aDio1twqJ/BXT0oy4oFOz+9JL+w7uUkWXnqSj4cDmXTvVRhqr9sg5ELeVjOxbWKjs7ax yQMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=I6Qf9WePQnjM1qP5GnvXQ6iGQgDn7ErWaVxKlruplAs=; b=VKQEFpXuUD/6QNr3ywWhKROJ/XlOT1jqVfDSPXRyluldLzOqwMB6Q5D1lf7KRfAISQ bL0HerS88FDnc0g0t1Jk/ucKEAmlpTCVhpSWh/NF5SV+TO+r4GAM3vVgIlFBzM0y6TM1 mu9Pm5nXfkcqPGs8enfKAabZ8fBsCG0QAXq71PhLzT05qRS7erq/1GQfjh7xfZykaIwu WIwm6ySIO7j9Pv+xsyHFgewZBnnAO6iXxHqgyKEj+mUrNvsdymM21puVsMmt015tGXsX lUPXCsECgXtnByF9Di5Fuea4hnZcxYSePM+A9iI1ClJg1ipPYaFhF6AsiUXEmlr19u2c 1Jqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id o3sor2007346wmo.17.2019.05.16.02.42.45 for (Google Transport Security); Thu, 16 May 2019 02:42:45 -0700 (PDT) Received-SPF: pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of oleksandr@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=oleksandr@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Google-Smtp-Source: APXvYqwocKMkkFgpDNBPx7AOMP66gc9e2eLJvBHtDID7H77ayfvD2k23YyAA2hs51SHVNKxVSScv4w== X-Received: by 2002:a1c:a695:: with SMTP id p143mr27260709wme.128.1557999764844; Thu, 16 May 2019 02:42:44 -0700 (PDT) Received: from localhost (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id t15sm4635388wmt.2.2019.05.16.02.42.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 May 2019 02:42:44 -0700 (PDT) From: Oleksandr Natalenko To: linux-kernel@vger.kernel.org Cc: Kirill Tkhai , Hugh Dickins , Alexey Dobriyan , Vlastimil Babka , Michal Hocko , Matthew Wilcox , Pavel Tatashin , Greg KH , Suren Baghdasaryan , Minchan Kim , Timofey Titovets , Aaron Tomlin , Grzegorz Halat , linux-mm@kvack.org, linux-api@vger.kernel.org Subject: [PATCH RFC 5/5] mm/ksm, proc: add remote madvise documentation Date: Thu, 16 May 2019 11:42:34 +0200 Message-Id: <20190516094234.9116-6-oleksandr@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516094234.9116-1-oleksandr@redhat.com> References: <20190516094234.9116-1-oleksandr@redhat.com> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Document respective /proc//madvise knob. Signed-off-by: Oleksandr Natalenko --- Documentation/filesystems/proc.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index 66cad5c86171..17106e435bba 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt @@ -45,6 +45,7 @@ Table of Contents 3.9 /proc//map_files - Information about memory mapped files 3.10 /proc//timerslack_ns - Task timerslack value 3.11 /proc//patch_state - Livepatch patch operation state + 3.12 /proc//madvise - Remote madvise 4 Configuring procfs 4.1 Mount options @@ -1948,6 +1949,18 @@ patched. If the patch is being enabled, then the task has already been patched. If the patch is being disabled, then the task hasn't been unpatched yet. +3.12 /proc//madvise - Remote madvise +-------------------------------------------- +This write-only file allows executing madvise operation for another task. + +If CONFIG_KSM is enabled, the following actions are available: + + * marking task's memory as mergeable: + # echo merge > /proc//madvise + + * unmerging all the task's memory: + # echo unmerge > /proc//madvise + ------------------------------------------------------------------------------ Configuring procfs