From patchwork Fri Jul 26 05:46:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11060331 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 EA6A313A0 for ; Fri, 26 Jul 2019 05:52:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D761C289DD for ; Fri, 26 Jul 2019 05:52:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAF9628A24; Fri, 26 Jul 2019 05:52:59 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 8D0AB289DD for ; Fri, 26 Jul 2019 05:52:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62C416B0003; Fri, 26 Jul 2019 01:52:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5DEC26B0005; Fri, 26 Jul 2019 01:52:57 -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 4CDA98E0002; Fri, 26 Jul 2019 01:52:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f70.google.com (mail-yw1-f70.google.com [209.85.161.70]) by kanga.kvack.org (Postfix) with ESMTP id 2C5136B0003 for ; Fri, 26 Jul 2019 01:52:57 -0400 (EDT) Received: by mail-yw1-f70.google.com with SMTP id h203so38620052ywb.9 for ; Thu, 25 Jul 2019 22:52:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:smtp-origin-hostprefix:from :smtp-origin-hostname:to:cc:smtp-origin-cluster:subject:date :message-id:in-reply-to:references:mime-version; bh=LjmLHqeEBIcPM1EzxLLHUMjC3IQ3Iyup262DaJYHDoM=; b=YXRNkm/eKsC8HEP2SFMgAdMQW2eglDg/geaM19ZCifg/HE0YgMw2GYxgSa0svZrVw6 ZaGxpT6MXsLWl1hBSaN8ZskJIn8lc0nqyp8KXfK60xWonRAZlf2tGuZavdIjQ4Dps6oc QpludcBJE7pa7QtPv5LogKOpsE91XmASwsiMPX+HqeJ6SPTTJ41XqNrg3okn5BwA2pz6 EKL7EUEu1E/LgsPMFhwLi116bW0K2t+FxFqDsB6H3+QEhqfqpUkZOCfZWD8sv4FysKGH Kj6j1+vlDQF1lhUy7RnObjGCuhFtsuQ3cPBHfTVrIeoDBrqq0vGvloBxnCBgVnl9VkzK ywnQ== X-Gm-Message-State: APjAAAVUbVFU2jhGww9m439Fz0EiVLUITXFUnIw2T5fcmcBnDWhQRh1d bTOy3gjmJumu/yRL8bVUPY3HMq8+BDuzcPZSXG5i7yTEwOwmv0gStknlv1QSrieHd9bx70FFU8w MRVMJqsiAFrTqN3gW/nx380++6B3xB6SZaELf9uu4kE5OSssrWaIMVv1vkE7Pgd1L2Q== X-Received: by 2002:a81:1f87:: with SMTP id f129mr54869392ywf.135.1564120376947; Thu, 25 Jul 2019 22:52:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvJNa8UA+MOtdg8TVnAwWfLNDY+I+pkXwkSjrxvJi/x4/EkVBKP1y0zZ0DY+dahe2YVarY X-Received: by 2002:a81:1f87:: with SMTP id f129mr54869376ywf.135.1564120376420; Thu, 25 Jul 2019 22:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564120376; cv=none; d=google.com; s=arc-20160816; b=Pn9/Tk72wUT6e2/WX+u3Il4SB+6Vr6hSAb6KySNsQ2/9HX+izWHsjAPlCwtxN323Vr pN9g+GI9gpS5Cx/ZVsjwqnBeOzhXQxEExFnoMbQiQE6d6/En8gsuI4VaeXLzxmAEeZBG x/9mOUQ+R3+8xeHYUzK0XFzVJ8tnzybP++1pVrUCh3hO7HBJNmxjZFo0SK3v1BNCYmFE rvHGGMldvfFwt1knLPTGmdjUPhsnPyfUGjOjs0Q0u0Oj+2ZTaG1XU3zypIFnTzYDfhE8 bF8hR2lSxkYSecScdumUWuojaupA62OVGp4LenVOaVkW5sVOJJf1NBKQwtQOr5+N0M5a BO4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:date:subject :smtp-origin-cluster:cc:to:smtp-origin-hostname:from :smtp-origin-hostprefix:dkim-signature; bh=LjmLHqeEBIcPM1EzxLLHUMjC3IQ3Iyup262DaJYHDoM=; b=SjqXWdSJ7ffcQtUGtNbP0doangLMZd1q5t7TSvXMIJ9RC+DB7BqHOhyUrAR68b8weG kFOgwV8GzJyyX8nVtqzeoP22WhOD8Imx7zI4Qlyqi83FvzDNj/mzVD6QIn9R9zxMZ1jZ 2xjv1/fQT3MOirJ1B2PjMZ1J/17R3j6ir+xS3ufQFApg9zeYbQ0tY5nG9+b0hbWUCz2d iVS5v5tZwOTuKMmQl+UJR+z9z6KP+ypfE6CwUWl9vqMzGoI4ejWFfQw5zetu6ucQJOEG kyfqSzJMi+i+fCnYQiLyTssUq2D8NzWAA6mngi3kFcku3qPd7staBZ1zlURLWPB7HvWG N0bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b="LJFRc4/W"; spf=pass (google.com: domain of prvs=21101f516b=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=21101f516b=songliubraving@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com. [67.231.153.30]) by mx.google.com with ESMTPS id d130si938205ywe.141.2019.07.25.22.52.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 22:52:56 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=21101f516b=songliubraving@fb.com designates 67.231.153.30 as permitted sender) client-ip=67.231.153.30; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b="LJFRc4/W"; spf=pass (google.com: domain of prvs=21101f516b=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=21101f516b=songliubraving@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6Q5nq2C007695 for ; Thu, 25 Jul 2019 22:52:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=LjmLHqeEBIcPM1EzxLLHUMjC3IQ3Iyup262DaJYHDoM=; b=LJFRc4/WlENKQaGEyhQOZPKAyhrCrHBmedVrQQOTZOteWyT7+449EpX7k3soqLKZ87sw V5tQTSb8+Fl2Cd81F2dtgJUZSQwkCEzYdGvBusb9d6s+bKhf2lzUgJtE4jyuNu5n6H1+ DFp2XW/xLLMibF6BDcB0grMYeAZMHFauzO4= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 2tyh40t29k-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 25 Jul 2019 22:52:55 -0700 Received: from mx-out.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::d) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 25 Jul 2019 22:52:54 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id CE79662E2FC5; Thu, 25 Jul 2019 22:47:09 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Song Liu Smtp-Origin-Hostname: devbig006.ftw2.facebook.com To: , , CC: , , , , , , , , Song Liu Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH v9 1/4] mm: move memcmp_pages() and pages_identical() Date: Thu, 25 Jul 2019 22:46:51 -0700 Message-ID: <20190726054654.1623433-2-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190726054654.1623433-1-songliubraving@fb.com> References: <20190726054654.1623433-1-songliubraving@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-26_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=974 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907260078 X-FB-Internal: deliver 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 This patch moves memcmp_pages() to mm/util.c and pages_identical() to mm.h, so that we can use them in other files. Acked-by: Kirill A. Shutemov Signed-off-by: Song Liu --- include/linux/mm.h | 7 +++++++ mm/ksm.c | 18 ------------------ mm/util.c | 13 +++++++++++++ 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 0334ca97c584..f189176dabed 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2891,5 +2891,12 @@ void __init setup_nr_node_ids(void); static inline void setup_nr_node_ids(void) {} #endif +extern int memcmp_pages(struct page *page1, struct page *page2); + +static inline int pages_identical(struct page *page1, struct page *page2) +{ + return !memcmp_pages(page1, page2); +} + #endif /* __KERNEL__ */ #endif /* _LINUX_MM_H */ diff --git a/mm/ksm.c b/mm/ksm.c index 3dc4346411e4..dbee2eb4dd05 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1029,24 +1029,6 @@ static u32 calc_checksum(struct page *page) return checksum; } -static int memcmp_pages(struct page *page1, struct page *page2) -{ - char *addr1, *addr2; - int ret; - - addr1 = kmap_atomic(page1); - addr2 = kmap_atomic(page2); - ret = memcmp(addr1, addr2, PAGE_SIZE); - kunmap_atomic(addr2); - kunmap_atomic(addr1); - return ret; -} - -static inline int pages_identical(struct page *page1, struct page *page2) -{ - return !memcmp_pages(page1, page2); -} - static int write_protect_page(struct vm_area_struct *vma, struct page *page, pte_t *orig_pte) { diff --git a/mm/util.c b/mm/util.c index e6351a80f248..0d5e2f425612 100644 --- a/mm/util.c +++ b/mm/util.c @@ -783,3 +783,16 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen) out: return res; } + +int memcmp_pages(struct page *page1, struct page *page2) +{ + char *addr1, *addr2; + int ret; + + addr1 = kmap_atomic(page1); + addr2 = kmap_atomic(page2); + ret = memcmp(addr1, addr2, PAGE_SIZE); + kunmap_atomic(addr2); + kunmap_atomic(addr1); + return ret; +} From patchwork Fri Jul 26 05:46:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11060337 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 61AA7112C for ; Fri, 26 Jul 2019 05:53:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F196289DD for ; Fri, 26 Jul 2019 05:53:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 432FD28A24; Fri, 26 Jul 2019 05:53:07 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 AB6B5289DD for ; Fri, 26 Jul 2019 05:53:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D8336B0007; Fri, 26 Jul 2019 01:53:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9897A6B0008; Fri, 26 Jul 2019 01:53:01 -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 7DB878E0002; Fri, 26 Jul 2019 01:53:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 44AB26B0007 for ; Fri, 26 Jul 2019 01:53:01 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id j22so32441916pfe.11 for ; Thu, 25 Jul 2019 22:53:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:smtp-origin-hostprefix:from :smtp-origin-hostname:to:cc:smtp-origin-cluster:subject:date :message-id:in-reply-to:references:mime-version; bh=qTMkWMk4VGQx15sS5BtWy4Evstd/NFMwWYqYg0rQQA8=; b=aQo2qP07Nad6/drJ9XqA+zobHnJRtJ5q1fEezYgKHzSN5FexQkVIkogEQ0EwiTe/zc Nnx4IwrsnEQ7G7Mfv/MMAhf0qvUlF6Bcp/NPJhJio1OlYV30kDb/vFOu3tsety6giU8V hyxnRax7enGyJOYLETZtJ7e6kDdgYJObuvXC+jmO/CFbBf2jw2d6fhrpX+mBxH0+ITDe BiJn1Yzv1b6E6XXYgWIp2wkEFg2y0WjCuWOfhxu93GE7i4ZA9S7WkkBwxyJTDKnG9PSU iM2tpGlAbiAa7Jqq4hbFoTWV2txmxm8pXLOcRf+5GPvdPR4lns+tVgghaFZv4cbgnQU6 4/eA== X-Gm-Message-State: APjAAAXkS3hbMgYYg0rJatTDa50vo88Q5ovXhMkALto6vMevo7ZZ9jtH qXP8UQ7gzLY5vHOF/4KyrclWQS8sYnT4TgPeIwXEkens0Ec5spCjFVdP9/EV+TTpF5JMMI+Vc0U I1UEwDMxiE5ZVXDhtFe/CY8WmjrGZcoOrHY0d6Zb1AeAzqSEVyw7Uzf4xbZY0/cnhdA== X-Received: by 2002:a63:4a51:: with SMTP id j17mr89499590pgl.284.1564120380623; Thu, 25 Jul 2019 22:53:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhTjrvdMtayzeeqZd24C1Rwwv1kl05YttbkVaUtTWrFIy97kttEHKE4HFP7HzcRCH+dbUd X-Received: by 2002:a63:4a51:: with SMTP id j17mr89499540pgl.284.1564120379809; Thu, 25 Jul 2019 22:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564120379; cv=none; d=google.com; s=arc-20160816; b=J35cwoaQXaU8BCg/KiBEzS5jNT7lP5WHRe4MZu+cP3U3Lir11Y6aqwMiX9/bOB++NW /W9ll5L/0QTLTHcu4X7xvVegGP76Q8MOyNzprggt+F249UuOpcxCBGyvs8fLYVQ56pjT jDOpKfWLH+vFWMhYWfzCifJzJVqPuIEwr9II/L81Tl3IKu/G1lU448RZoj9vax7jbP95 7z8SsLOZhBz6S67YXTDl75a0vpAcqUfJGmXhpwlhM1GyS1bN6Ba1PRFG9XUvlWzeFYGK ojcrjw7zyYvuf5p5SvTfApcKfA1fyyGGk6YJHBmMvgbwTTfY3+SXbq8oVeXv1Q5S/jVa MxJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:date:subject :smtp-origin-cluster:cc:to:smtp-origin-hostname:from :smtp-origin-hostprefix:dkim-signature; bh=qTMkWMk4VGQx15sS5BtWy4Evstd/NFMwWYqYg0rQQA8=; b=xcojd9VR+G2BQKIxsaTaOLvQsAJ1JicSzVNjK1cqezfw8yNZOlA6YpkmN1Fib2IZm6 zNlnPFWSkzvJ2+/xQhgWCJ6BJKXGPDa/7OHibJw0LR5EJKHx6cNwZif2n+pRm0QZ2pNp LZkjI7m1bzYN42sGPsZKYnXVNSBuhNoekw9fDuwQp4/HYyjHsK3Dbvdxw89jANy5vJum XLFfBL81rbnU+9EWpHY8nc9uX9q2xRK5DOk5ZwpzTP3ISNnCkuYcIedKnWYDeexJXbGR 9gTqQucXf/5N7kZlNetdz1HBDFiyFtWPskRDgNv49LeCmkMwQ4FfzGPOAgcoWI2rUC0K O2vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=cYGzbKEh; spf=pass (google.com: domain of prvs=21101f516b=songliubraving@fb.com designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=21101f516b=songliubraving@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com. [67.231.145.42]) by mx.google.com with ESMTPS id s7si20805442plp.66.2019.07.25.22.52.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 22:52:59 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=21101f516b=songliubraving@fb.com designates 67.231.145.42 as permitted sender) client-ip=67.231.145.42; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=cYGzbKEh; spf=pass (google.com: domain of prvs=21101f516b=songliubraving@fb.com designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=21101f516b=songliubraving@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6Q5qvM5004139 for ; Thu, 25 Jul 2019 22:52:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=qTMkWMk4VGQx15sS5BtWy4Evstd/NFMwWYqYg0rQQA8=; b=cYGzbKEhyWdo5VGRzg3veJjaKtBljDnewaFyiPtQAT0cQP0/2xtTcUCQv7I9A4x2zhyj +5vWux/EE1EclvSSYmiXepfDnY1CJDqmZuzpHDeijhe5kd3atWSUkNLQKQHNo7TKLc4R pCU4HExRdkwdNCUnCsWcmf5PobbanIE+9hQ= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 2tyqae8pwg-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 25 Jul 2019 22:52:58 -0700 Received: from mx-out.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 25 Jul 2019 22:52:53 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id C109A62E300E; Thu, 25 Jul 2019 22:47:14 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Song Liu Smtp-Origin-Hostname: devbig006.ftw2.facebook.com To: , , CC: , , , , , , , , Song Liu Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH v9 2/4] uprobe: use original page when all uprobes are removed Date: Thu, 25 Jul 2019 22:46:52 -0700 Message-ID: <20190726054654.1623433-3-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190726054654.1623433-1-songliubraving@fb.com> References: <20190726054654.1623433-1-songliubraving@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-26_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=891 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907260078 X-FB-Internal: deliver 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 Currently, uprobe swaps the target page with a anonymous page in both install_breakpoint() and remove_breakpoint(). When all uprobes on a page are removed, the given mm is still using an anonymous page (not the original page). This patch allows uprobe to use original page when possible (all uprobes on the page are already removed). As suggested by Oleg, we unmap the old_page and let the original page fault in. Suggested-by: Oleg Nesterov Signed-off-by: Song Liu --- kernel/events/uprobes.c | 62 +++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 15 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 84fa00497c49..bd248af7310c 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -143,10 +143,12 @@ static loff_t vaddr_to_offset(struct vm_area_struct *vma, unsigned long vaddr) * * @vma: vma that holds the pte pointing to page * @addr: address the old @page is mapped at - * @page: the cowed page we are replacing by kpage - * @kpage: the modified page we replace page by + * @old_page: the page we are replacing by new_page + * @new_page: the modified page we replace page by * - * Returns 0 on success, -EFAULT on failure. + * If @new_page is NULL, only unmap @old_page. + * + * Returns 0 on success, negative error code otherwise. */ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, struct page *old_page, struct page *new_page) @@ -166,10 +168,12 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, VM_BUG_ON_PAGE(PageTransHuge(old_page), old_page); - err = mem_cgroup_try_charge(new_page, vma->vm_mm, GFP_KERNEL, &memcg, - false); - if (err) - return err; + if (new_page) { + err = mem_cgroup_try_charge(new_page, vma->vm_mm, GFP_KERNEL, + &memcg, false); + if (err) + return err; + } /* For try_to_free_swap() and munlock_vma_page() below */ lock_page(old_page); @@ -177,15 +181,18 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, mmu_notifier_invalidate_range_start(&range); err = -EAGAIN; if (!page_vma_mapped_walk(&pvmw)) { - mem_cgroup_cancel_charge(new_page, memcg, false); + if (new_page) + mem_cgroup_cancel_charge(new_page, memcg, false); goto unlock; } VM_BUG_ON_PAGE(addr != pvmw.address, old_page); - get_page(new_page); - page_add_new_anon_rmap(new_page, vma, addr, false); - mem_cgroup_commit_charge(new_page, memcg, false, false); - lru_cache_add_active_or_unevictable(new_page, vma); + if (new_page) { + get_page(new_page); + page_add_new_anon_rmap(new_page, vma, addr, false); + mem_cgroup_commit_charge(new_page, memcg, false, false); + lru_cache_add_active_or_unevictable(new_page, vma); + } if (!PageAnon(old_page)) { dec_mm_counter(mm, mm_counter_file(old_page)); @@ -194,8 +201,9 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, flush_cache_page(vma, addr, pte_pfn(*pvmw.pte)); ptep_clear_flush_notify(vma, addr, pvmw.pte); - set_pte_at_notify(mm, addr, pvmw.pte, - mk_pte(new_page, vma->vm_page_prot)); + if (new_page) + set_pte_at_notify(mm, addr, pvmw.pte, + mk_pte(new_page, vma->vm_page_prot)); page_remove_rmap(old_page, false); if (!page_mapped(old_page)) @@ -501,8 +509,32 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm, copy_highpage(new_page, old_page); copy_to_page(new_page, vaddr, &opcode, UPROBE_SWBP_INSN_SIZE); + /* try orig_page only for unregister and anonymous old_page */ + if (!is_register && PageAnon(old_page)) { + struct page *orig_page; + pgoff_t index; + + index = vaddr_to_offset(vma, vaddr & PAGE_MASK) >> PAGE_SHIFT; + orig_page = find_get_page(vma->vm_file->f_inode->i_mapping, + index); + + if (orig_page) { + if (PageUptodate(orig_page) && + pages_identical(new_page, orig_page)) { + /* let go new_page */ + put_page(new_page); + new_page = NULL; + + /* dec_mm_counter for old_page */ + dec_mm_counter(mm, MM_ANONPAGES); + } + put_page(orig_page); + } + } + ret = __replace_page(vma, vaddr, old_page, new_page); - put_page(new_page); + if (new_page) + put_page(new_page); put_old: put_page(old_page); From patchwork Fri Jul 26 05:46:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11060335 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 A5420112C for ; Fri, 26 Jul 2019 05:53:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 946C828A0B for ; Fri, 26 Jul 2019 05:53:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8846F28A4F; Fri, 26 Jul 2019 05:53:04 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 0F20428A24 for ; Fri, 26 Jul 2019 05:53:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 548636B0006; Fri, 26 Jul 2019 01:53:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 396F46B0007; Fri, 26 Jul 2019 01:53:00 -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 212C08E0002; Fri, 26 Jul 2019 01:53:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f71.google.com (mail-yw1-f71.google.com [209.85.161.71]) by kanga.kvack.org (Postfix) with ESMTP id F2B036B0006 for ; Fri, 26 Jul 2019 01:52:59 -0400 (EDT) Received: by mail-yw1-f71.google.com with SMTP id i63so38830233ywc.1 for ; Thu, 25 Jul 2019 22:52:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:smtp-origin-hostprefix:from :smtp-origin-hostname:to:cc:smtp-origin-cluster:subject:date :message-id:in-reply-to:references:mime-version; bh=YpPGU3ZiU++0VQgyDS3QSdQ0lQHIOIN4ED9AD9AHh/Y=; b=HWLW4NZvi7CxPdvKx5+cfMPaAZPo17xS1v3zpxY82gvmzGt2hEKEj/idZgloQyZnuw VH5GxNuzisTkN3bLd7EpxDGd0nEkTT6dNQoMejZ7Rzyn3KY/mMZCROjCR8COsqhObHT1 IUN/tvJjcgyehjXuiD20Gp+oII+pTXjeJlC495I16R845O0z5aCPyWa40KcfwJYrzxZs 0H8mJKQ/Px4U64eryvVgecvcnbpup45NF6ZBffAiSw8d6SvmD9OA5yb5KhOpkoaXdbMZ pRrTHqfoc4Zr5dpPtxG1tDlT0OLu8QIYbwlWFrkKfGcrTmDpgYMj2n2b56m1VGR8djwq PIdQ== X-Gm-Message-State: APjAAAVRPStsXuzIe/AwdeiLoXe7EL0lsBLAj/hypItJPgfIK2CFGEpc gvPMVGloiODjncAukny0hwxrapk709L072u3h+cTChidVNxqRu4iTicY1caC4TH0qp/daagN7Wv exCVerGw4g23wFNEVNdy/emVlPGLYzwhWYkdC8NY49UZQjqROI59KKTb4dwCNjgn0hg== X-Received: by 2002:a25:d289:: with SMTP id j131mr58027468ybg.91.1564120379773; Thu, 25 Jul 2019 22:52:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwx5fe38ZVzL5adCv5QGj4Q2/vTh+d7KxV4/ZKSQUckfqM+m2FWXFbX4ToheQSl51Klewl6 X-Received: by 2002:a25:d289:: with SMTP id j131mr58027453ybg.91.1564120379298; Thu, 25 Jul 2019 22:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564120379; cv=none; d=google.com; s=arc-20160816; b=Xk+0JkWamcBBr/amNPPhxr9c7Z/Cg6HlTOCs1vpLhtPqostQCft82i1jsCVPDwcLNA Y+cxyJMgGC9sHkf5jThSJ6b9ujOmLqiNgJkUoEJCdLsBfRiTkYH4ub1IIaRpkL8UWGrS 9Idcj0PCQC7+eP0ZdzPyorhSiq8bn5VEM7bfA5La+R9gSX5rePSu3UIiEz3k1QDElk4w qVRU2f+Yt85NJfFErlFTzVgV+St4qbX65I5OhBbUfoA/y2DP/YDcNX+D8Gw9HV2ePvaz a7dwR03Q7+SS6HxecMbRMFiouLOcoWZ+EHyq/ekK9tcZVaflEfjnyG+cgCPeSxGBrKjM pJDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:date:subject :smtp-origin-cluster:cc:to:smtp-origin-hostname:from :smtp-origin-hostprefix:dkim-signature; bh=YpPGU3ZiU++0VQgyDS3QSdQ0lQHIOIN4ED9AD9AHh/Y=; b=aO6Zmzc1SyC4QG1IBwSZlEf41YxmwpEpX9OUuDDBeCx2CaoSsXyfHdMeX2/SBU1vWQ eHWRyWkNF2OKn+0mOHnlSotVwzma0RYEi5fZZSSSLOixeBqJ4XFqvaFshsIctU86EIFN +4FyKghr1boi1mFPHZ0F9Qqkgd0UkxA+5XEz7qBU3pkIm2RQY+ewy9rf0Rcso8jNaU0o toDbhKb6Otus5uaA/sTjEfpylX/6RyHpjkNJwnjw/GdpCdbhbYEd6vUn98Kp6KSycKIH sAkU/gAQRkK9+UeY/BKotsOLy7EKxZPiyeDK1YSUFAZQqbEawfsbqeS1nFtbQcI6hFLc hz5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=jndW4AKC; spf=pass (google.com: domain of prvs=21101f516b=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=21101f516b=songliubraving@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com. [67.231.153.30]) by mx.google.com with ESMTPS id n3si17925157ywd.189.2019.07.25.22.52.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 22:52:59 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=21101f516b=songliubraving@fb.com designates 67.231.153.30 as permitted sender) client-ip=67.231.153.30; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=jndW4AKC; spf=pass (google.com: domain of prvs=21101f516b=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=21101f516b=songliubraving@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.27/8.16.0.27) with SMTP id x6Q5qC5u013835 for ; Thu, 25 Jul 2019 22:52:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=YpPGU3ZiU++0VQgyDS3QSdQ0lQHIOIN4ED9AD9AHh/Y=; b=jndW4AKCC04H2racbu/QH+nObjPHzUAhRUY5hpwh+DjuvLEh/+O50CTcsYrb+Ri9Wwgn DtjHtmInDofnmNuig8VfsT4ieBGgohij/gOjxG2OQYV0UWXm/MvpocuH8B2tLrmAcYHN TETuNiDLvMlUujmnmCTg2IX7ekQVoRjMQ+M= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by m0001303.ppops.net with ESMTP id 2tye8mawqw-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 22:52:58 -0700 Received: from mx-out.facebook.com (2620:10d:c081:10::13) by mail.thefacebook.com (2620:10d:c081:35::127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1713.5; Thu, 25 Jul 2019 22:52:55 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id 1DFB362E3049; Thu, 25 Jul 2019 22:47:18 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Song Liu Smtp-Origin-Hostname: devbig006.ftw2.facebook.com To: , , CC: , , , , , , , , Song Liu Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH v9 3/4] mm, thp: introduce FOLL_SPLIT_PMD Date: Thu, 25 Jul 2019 22:46:53 -0700 Message-ID: <20190726054654.1623433-4-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190726054654.1623433-1-songliubraving@fb.com> References: <20190726054654.1623433-1-songliubraving@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-26_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907260078 X-FB-Internal: deliver 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 This patches introduces a new foll_flag: FOLL_SPLIT_PMD. As the name says FOLL_SPLIT_PMD splits huge pmd for given mm_struct, the underlining huge page stays as-is. FOLL_SPLIT_PMD is useful for cases where we need to use regular pages, but would switch back to huge page and huge pmd on. One of such example is uprobe. The following patches use FOLL_SPLIT_PMD in uprobe. Acked-by: Kirill A. Shutemov Signed-off-by: Song Liu --- include/linux/mm.h | 1 + mm/gup.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index f189176dabed..74db879711eb 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2614,6 +2614,7 @@ struct page *follow_page(struct vm_area_struct *vma, unsigned long address, #define FOLL_COW 0x4000 /* internal GUP flag */ #define FOLL_ANON 0x8000 /* don't do file mappings */ #define FOLL_LONGTERM 0x10000 /* mapping lifetime is indefinite: see below */ +#define FOLL_SPLIT_PMD 0x20000 /* split huge pmd before returning */ /* * NOTE on FOLL_LONGTERM: diff --git a/mm/gup.c b/mm/gup.c index 98f13ab37bac..3c514e223ce3 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -399,7 +399,7 @@ static struct page *follow_pmd_mask(struct vm_area_struct *vma, spin_unlock(ptl); return follow_page_pte(vma, address, pmd, flags, &ctx->pgmap); } - if (flags & FOLL_SPLIT) { + if (flags & (FOLL_SPLIT | FOLL_SPLIT_PMD)) { int ret; page = pmd_page(*pmd); if (is_huge_zero_page(page)) { @@ -408,7 +408,7 @@ static struct page *follow_pmd_mask(struct vm_area_struct *vma, split_huge_pmd(vma, pmd, address); if (pmd_trans_unstable(pmd)) ret = -EBUSY; - } else { + } else if (flags & FOLL_SPLIT) { if (unlikely(!try_get_page(page))) { spin_unlock(ptl); return ERR_PTR(-ENOMEM); @@ -420,6 +420,10 @@ static struct page *follow_pmd_mask(struct vm_area_struct *vma, put_page(page); if (pmd_none(*pmd)) return no_page_table(vma, flags); + } else { /* flags & FOLL_SPLIT_PMD */ + spin_unlock(ptl); + split_huge_pmd(vma, pmd, address); + ret = pte_alloc(mm, pmd); } return ret ? ERR_PTR(ret) : From patchwork Fri Jul 26 05:46:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11060333 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 F39A013A0 for ; Fri, 26 Jul 2019 05:53:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E351F28A0B for ; Fri, 26 Jul 2019 05:53:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D621F28A4F; Fri, 26 Jul 2019 05:53:01 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 6115E28A0B for ; Fri, 26 Jul 2019 05:53:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 172F66B0005; Fri, 26 Jul 2019 01:52:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0FEE16B0006; Fri, 26 Jul 2019 01:52:58 -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 E880A8E0002; Fri, 26 Jul 2019 01:52:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f72.google.com (mail-yw1-f72.google.com [209.85.161.72]) by kanga.kvack.org (Postfix) with ESMTP id C8BAD6B0005 for ; Fri, 26 Jul 2019 01:52:57 -0400 (EDT) Received: by mail-yw1-f72.google.com with SMTP id b188so38445889ywb.10 for ; Thu, 25 Jul 2019 22:52:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:smtp-origin-hostprefix:from :smtp-origin-hostname:to:cc:smtp-origin-cluster:subject:date :message-id:in-reply-to:references:mime-version; bh=UDDhhnpIwhL65SFKuOG28sTsSPl2JTdHqEX1HZsGTmw=; b=Cftr84R0RMRznzz3KQQZLDATmQGpKQVY8YnFHCBXk0mwLBxCbxGhfheVx1AjAxvGXF boPbgv/0/gi2/4roipo8PBW07EiMhKR5Ov8TqkAnctTuatZEwPlE2OcYNadmkpfPZEkI jeUlN+gBZ8Y7/GeLGha3oj+JzjLnvOqsMbNgtKAuvHzcEKwF5eXHNAdvig55Vs0LPBkA /ka/LSBIzloAKzwmvngin42F/71ySCvyxtPkz5mLilBuhtGFsDqjg0MzZSvfDE5urVCU q3BVHW02DvPFRm/pwOVzNNQigcTy98kbv9txmc/n//G4LaIUZZTzMqTa0yoCC/jztSyf Ziww== X-Gm-Message-State: APjAAAUeTLHTn6XlsvMaH/RRgo5AY1mFo4nkSi91HtWfbkQW7nN/S1oC txWbIBBzDr3YcjSEADd0WwgKcCT00LJ7eh/GYiAmhYv6U4CLDl4paV1YrMEzJeBnc/B8Kfx3AuN iFK77JJcy37cki2x6qOzALN3PAMWormFkODulG4f9Yth3kv4CirpRLYzK3//4sllz4A== X-Received: by 2002:a81:6d07:: with SMTP id i7mr58607320ywc.112.1564120377619; Thu, 25 Jul 2019 22:52:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOYKwxfdG39SPcz+KUg8C7HIfma0g2QmuaLUgvtWkuHjJ3rfBwlcnEz2451VJoxbC5Z51r X-Received: by 2002:a81:6d07:: with SMTP id i7mr58607315ywc.112.1564120377190; Thu, 25 Jul 2019 22:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564120377; cv=none; d=google.com; s=arc-20160816; b=CBkE37amxX9UGZ1yZz8UmHbw4DaNp8mha1zf9khxaV5RKSuX5b2gCybGvHutvE2YrC XZ+4jVV69RwL0J+UN09eNjr5AlfeL0CijunARpuuOz5S6kc0l4amYTgoIMuVXVEjtHJn 1CTYDK7YjAzKcD2l080UyPc6AaQWG3ojvcK8ddTuczxNIxqPcld6uD7AiV95mIzoSdT5 aCwDlDIkt7OpjKmDwuvOerK3nPUkBlRgvGGrV2Udwdn+JCpEV48LWSzYckzt7I9CLXpT 5kn2cKCiKGAYyTP4zGc1lf73CFKNhOWxo9ohwKjDfJNQZEFHICQp7nex9uVwM5o1OY2X jRNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:date:subject :smtp-origin-cluster:cc:to:smtp-origin-hostname:from :smtp-origin-hostprefix:dkim-signature; bh=UDDhhnpIwhL65SFKuOG28sTsSPl2JTdHqEX1HZsGTmw=; b=ANnwYQqsWrElssOtmc4ZzHGZvYzQj9xBUOQWH/sWJmnLbQffANdzaj7Kt1eu0iTxeH qRHlL5lnbE9jrcszl7FqAgqJ9ZxVkYCG8c4JKCSlOTj5Cn2I313tGJnY2UKI/tIk7qVQ iSwEKB6K3azae7gLMZL8Rz2Af/oYS7emSrZMgwwkZ2+r4Ox5ih/g8OOSm2HLUpEPpseC mUJSnqQnAn1Lk77t2aqdxLQyjRlJWeZBNs62eBLYxclrbginTB8KzTp5IsGyQ/b+nUuA NKtz/a2BGTKwnxQdUHAnT5DX6eYZ2BLbHDmGHX+qyT5TAOgz1C7BWAy5365MQvVLriVw HsgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=JZ39mimo; spf=pass (google.com: domain of prvs=21101f516b=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=21101f516b=songliubraving@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com. [67.231.153.30]) by mx.google.com with ESMTPS id q1si19029885ywd.77.2019.07.25.22.52.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 22:52:57 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=21101f516b=songliubraving@fb.com designates 67.231.153.30 as permitted sender) client-ip=67.231.153.30; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=JZ39mimo; spf=pass (google.com: domain of prvs=21101f516b=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=21101f516b=songliubraving@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.27/8.16.0.27) with SMTP id x6Q5qC5p013835 for ; Thu, 25 Jul 2019 22:52:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=UDDhhnpIwhL65SFKuOG28sTsSPl2JTdHqEX1HZsGTmw=; b=JZ39mimog7+GeZFLDwQxFCXtIubs8LHH3C5++YUmetQnVjLjCI96xwEiP14uFhHYa2Ej cxQluds+zdHsKlqjoplamVPLFj+PWx/RZgVJUdbuE+P030nlSzhH3jzmzGjE4pxRUY91 vDGy6hlWNVJqwXXND5AP8GRpPqNsmkQ3wOk= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by m0001303.ppops.net with ESMTP id 2tye8mawqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 22:52:56 -0700 Received: from mx-out.facebook.com (2620:10d:c081:10::13) by mail.thefacebook.com (2620:10d:c081:35::127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1713.5; Thu, 25 Jul 2019 22:52:54 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id 78FF462E305E; Thu, 25 Jul 2019 22:47:20 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Song Liu Smtp-Origin-Hostname: devbig006.ftw2.facebook.com To: , , CC: , , , , , , , , Song Liu Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH v9 4/4] uprobe: use FOLL_SPLIT_PMD instead of FOLL_SPLIT Date: Thu, 25 Jul 2019 22:46:54 -0700 Message-ID: <20190726054654.1623433-5-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190726054654.1623433-1-songliubraving@fb.com> References: <20190726054654.1623433-1-songliubraving@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-26_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=710 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907260078 X-FB-Internal: deliver 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 This patches uses newly added FOLL_SPLIT_PMD in uprobe. This enables easy regroup of huge pmd after the uprobe is disabled (in next patch). Acked-by: Kirill A. Shutemov Reviewed-by: Srikar Dronamraju Signed-off-by: Song Liu Acked-by: Kirill A. Shutemov Reviewed-by: Srikar Dronamraju Signed-off-by: Song Liu --- kernel/events/uprobes.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index bd248af7310c..58ab7fc7272a 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -155,7 +155,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, { struct mm_struct *mm = vma->vm_mm; struct page_vma_mapped_walk pvmw = { - .page = old_page, + .page = compound_head(old_page), .vma = vma, .address = addr, }; @@ -166,8 +166,6 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, mm, addr, addr + PAGE_SIZE); - VM_BUG_ON_PAGE(PageTransHuge(old_page), old_page); - if (new_page) { err = mem_cgroup_try_charge(new_page, vma->vm_mm, GFP_KERNEL, &memcg, false); @@ -479,7 +477,7 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm, retry: /* Read the page with vaddr into memory */ ret = get_user_pages_remote(NULL, mm, vaddr, 1, - FOLL_FORCE | FOLL_SPLIT, &old_page, &vma, NULL); + FOLL_FORCE | FOLL_SPLIT_PMD, &old_page, &vma, NULL); if (ret <= 0) return ret;