From patchwork Wed Jul 24 08:35:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11056341 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 10A2B6C5 for ; Wed, 24 Jul 2019 08:38:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0108E28732 for ; Wed, 24 Jul 2019 08:38:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E985828785; Wed, 24 Jul 2019 08:38:32 +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 7440528732 for ; Wed, 24 Jul 2019 08:38:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E97DE6B0008; Wed, 24 Jul 2019 04:38:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E4B666B000A; Wed, 24 Jul 2019 04:38:24 -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 D37B76B000C; Wed, 24 Jul 2019 04:38:24 -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 B09C06B0008 for ; Wed, 24 Jul 2019 04:38:24 -0400 (EDT) Received: by mail-yw1-f70.google.com with SMTP id 77so34156696ywp.14 for ; Wed, 24 Jul 2019 01:38:24 -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=eoG9KyvLhlYE00FluZL3g7CcZO+Du9sWRL0eYJzs+KHvNQsw5h7q2hpkfKMjrrVYJ+ IIg7HZ4TeLPGVsYb0jzWY0XzTc/3wTbGm8q5m2+xF6UsRm57J7SPa49jUENsbTpZaw5g JMPCfkEZSbYWS8q/5y4fsJoRGoABm+3i3B0QSQfHiejd9DDj72ZPHT6obzlhJ1PFiZZb XHVWSYKAkBwnnPhbWYCvV2ePEZjyHg4jxBpYpX0Qx00gBYt+tCgvLctaQh/RL3Y8nmXJ 7JP6WQz0KI4gWeobVXcAOp7Kd460YvrZQi6G+leggHgqBvODBcpZtC8Mapm69Km+A2SY tbBw== X-Gm-Message-State: APjAAAWY8VHc4i92cjcydWvokuHhCeeApDaH+gBE4aUABCfs+MpgmTuu Nf/hnRHAoz4RWb4lvr8vda56Us7MNIPoM4OSm6iRlEIDOPMAH4CYZrrcK/4nTQ6roce0rf2RL+e Q8UzWTaOmB4VtZPzcVoscck32WMbRGHZyaY3/n7LTrjerfHf2/Ffl5RUqFcXfx9CkzA== X-Received: by 2002:a25:830e:: with SMTP id s14mr50083353ybk.500.1563957504449; Wed, 24 Jul 2019 01:38:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3/k+eheJPZVfFPWrI6d6YdfV5EIQMjbyMQMjXUFkOielZyfR5KZ347hKo+q0MdnA24Rbc X-Received: by 2002:a25:830e:: with SMTP id s14mr50083338ybk.500.1563957503923; Wed, 24 Jul 2019 01:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563957503; cv=none; d=google.com; s=arc-20160816; b=LJexCS7xzPBJiRU9VX7tSV8rhunonlZcfHslo0w6T0jjW84CrL5fposg+G+wEa2d0m 0sGJDvdnV1KVwn4SKjWsa42ESDFFw/OmLskLBSpg7eRpi5oHGcZb0zKtqX1s8tvpWqdr eSQuuGNTQHg/IrWzY7ocn5V7P7N/k9FlerWLnq5+x6yxBpB4H4k8NFte5JdIBQiT5wcf gR+hNem12Ow+5190pdPpsQ0IB429MLj7gsKha+uUO6NTC4/6TTihadawA+fScgX0plJG JMgZE0K3Q6v0DmAUpzTwqGItfSUhO/A8Ji4Y2Hbe7xieeYVQh8EMnP7s9ymuMU9mP/Fj 3avg== 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=tuCMjrlbXzrIDjPzWA0tTZzGgEwWDMUypYdykJ886NIozvfK3g1XxTqlWx7N9/jBW2 hz+UpbJ4QQ63rspKfIJu8nBzuZjLaB89MCjLLhwyiEjK/4V1Urx1327VLmv+fPnFG3a0 XrMdMQ9VrNi0j7LGl1b1TZu8E0Gyv0z/y6rRsreEOs9dPHP5WJrGx4sKz2Z11+OtvNPV ieNT6jjmIAfCcGN5UMaApzcfTlFPcJDAD0cFOUlqFbr8HI0vdlVFmvG9fVCzANc9ddai 9PZ0Z82s2x7a6BuxWqGKfAIAm/DwkxIcxzpLCdIYGVzBPZdfij+ckcBTcK6MAOq15Aiq em+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=qngBAmzE; spf=pass (google.com: domain of prvs=21083052e4=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=21083052e4=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 v193si15184740ybv.496.2019.07.24.01.38.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jul 2019 01:38:23 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=21083052e4=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=qngBAmzE; spf=pass (google.com: domain of prvs=21083052e4=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=21083052e4=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 x6O8b4dq028464 for ; Wed, 24 Jul 2019 01:38:23 -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=qngBAmzEIM8Bkk0aumHkSmeqkqIHn9isMrPgNPQrHEQopUf9EC4DxYUdbh+KXlshcbxj FYdyMVVl45rhaUkkcDViOP03E6fIQNlLNEbj2mrZKRyft4MB2001HCjqZz6gwTzcj0fe YaPxu6TP1bZr+B2nhypi2iiyYr9VheBxxcE= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by m0001303.ppops.net with ESMTP id 2tx613jw2x-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 24 Jul 2019 01:38:23 -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; Wed, 24 Jul 2019 01:38:19 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id 5009762E30CD; Wed, 24 Jul 2019 01:36: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 v8 1/4] mm: move memcmp_pages() and pages_identical() Date: Wed, 24 Jul 2019 01:35:57 -0700 Message-ID: <20190724083600.832091-2-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190724083600.832091-1-songliubraving@fb.com> References: <20190724083600.832091-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-24_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=947 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907240097 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 Wed Jul 24 08:35:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11056335 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 404E413A0 for ; Wed, 24 Jul 2019 08:38:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3060428689 for ; Wed, 24 Jul 2019 08:38:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2477E28782; Wed, 24 Jul 2019 08:38:25 +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 98C6328689 for ; Wed, 24 Jul 2019 08:38:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A9556B0005; Wed, 24 Jul 2019 04:38:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 682918E0002; Wed, 24 Jul 2019 04:38:21 -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 500AE6B0008; Wed, 24 Jul 2019 04:38:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id F177C6B0005 for ; Wed, 24 Jul 2019 04:38:20 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id e20so28097063pfd.3 for ; Wed, 24 Jul 2019 01:38:20 -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=Sr6wWULEM6szvGRjJ+9iWCVQfCXAA0jyuXknznuqFcU=; b=LfYZo0OXcIHFGErw1BDv+MCZG8S1BCFGkmUYp/WedCGA+//xRk6UqvUs3W1VCbwH1j iyzIqOmJE33DcWa1Wjt5wVHWCexdqsjDIbWFa5vIArxtjoEM1jxYIOZet1AOaCFCjuQJ 5cQ+BuxBR5V7+yH6Uaiud6lOlfxJFZZV2TULGiCdyrCCxEAyrD9ZDkZYzOlKDft4rXEX 9CA2yH9ripNXyU7FQJeX4KmDfAl/esestNwSaN+1hl27ZjpMJBFDSoDcpqzxmTE7hT+i aAQtXPgCoOiumtpfCzUagKI7IY1oFp24/LmUolECdK/8Ne+cyZqwY73yGriFxztkPQXH GKJw== X-Gm-Message-State: APjAAAWxPYo7lTf6UO23KMXv++KMzDZx4uGbArVB0TOqGKFdvIm7D/JT lsXqV+zfDPx1Qo6viNid345WK+JeYBB5XxmOzZ5YLnAh/sCaYMcthqQPDlJps2m+obGlAZLJOs3 LVjUqBt5HIl/rgXfcrrbsptqdwDy94t4PNecRzIOnjMl5z5ol8vEjMBoRS0UViz0uwQ== X-Received: by 2002:a17:90a:28e4:: with SMTP id f91mr83730812pjd.99.1563957500665; Wed, 24 Jul 2019 01:38:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgoBTIJ3TSxHqDWyKt3GQJ/f6aY79Ppi7ab5U8TSY8XdOolZjifPDX2h8iz5lqzXJkdyKU X-Received: by 2002:a17:90a:28e4:: with SMTP id f91mr83730772pjd.99.1563957499993; Wed, 24 Jul 2019 01:38:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563957499; cv=none; d=google.com; s=arc-20160816; b=RSgivD/PbkPCh6aeg2v9iG3mNJ/11mr2evXXXfH60vBU3fAlih7Jd2gzZ6rLfehPLO KyFzCvN2b0MIbjlvb59MTvNBznug7SPaExMO2lO+RSiZ+PjJZgTwEQNrN1fLsNDFBNYF bcuUFsKL5SfgzThJS2o4c6hfDHr4ld6l5mMclJWvfqgKx6WX99nrCaOP3p38zLAJPcHr 0m4bHrOhNIK1Hw44jIDvUD0duW2Xt2w8KJHj+9FFLyJcVTrZUsAw4vp0ID2VeCsfoWjN t3kQ2wCwrHjaE4Tw1KtC3MF/Pe0aB5zSwtN7pvCqACfaHt3CYVmnqfIplvG/Lef8DWwz Hvzw== 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=Sr6wWULEM6szvGRjJ+9iWCVQfCXAA0jyuXknznuqFcU=; b=Zg/ZejPzW0RT+D9msZx0+NDqmCTfhlX2ccyt6pz7xY+KOYgGF8RxgGfkO6EtPmh7qq NlYLi0UO1M4dlhlO4ZEmyVawZzYzEXvtOWk2BK7zoJVEJUCEpNbwiQ3c7H07AX1SHzba MvrbUnKcF75Miidl4BwCyTPSXFqdccT+2IGBMO9LhVX8GNm1ImFfd7oruFCzB8heuOuV bnr46Exl2MjZWx3rEkoD4kUHcmgZkkhtapjd7TVWblNcv1OCRYsKna/yyOkySh4Y9b1Y EOAvFb9LOhgCqIcXGobqjZUbnjarF9SehZMJ5oXy59YMUID1yluHMraqhgx/b+17r9k9 zIXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=n29xeY+n; spf=pass (google.com: domain of prvs=21083052e4=songliubraving@fb.com designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=21083052e4=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 q10si13324994pgf.529.2019.07.24.01.38.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jul 2019 01:38:19 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=21083052e4=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=n29xeY+n; spf=pass (google.com: domain of prvs=21083052e4=songliubraving@fb.com designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=21083052e4=songliubraving@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6O8bZ9x021055 for ; Wed, 24 Jul 2019 01:38:19 -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=Sr6wWULEM6szvGRjJ+9iWCVQfCXAA0jyuXknznuqFcU=; b=n29xeY+nC4EEVyYZoBVoxKpz0ZfB2ImFgpNVh0tUTMPZVR4x5UOfhkFp/BEIjk7hLtjU uG3kE4/BSwPmxryOnjEoDe2UObAVMmf+1Z3TZDcAcvrYsu9WjjoSiyaGo8b6MFx70tti bhDPx3oMj8WwxWgv81q5MsKqHnzIZFSD9zQ= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 2txe7x91w8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 24 Jul 2019 01:38:19 -0700 Received: from mx-out.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 24 Jul 2019 01:38:17 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id E96BC62E30DB; Wed, 24 Jul 2019 01:36:11 -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 v8 2/4] uprobe: use original page when all uprobes are removed Date: Wed, 24 Jul 2019 01:35:58 -0700 Message-ID: <20190724083600.832091-3-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190724083600.832091-1-songliubraving@fb.com> References: <20190724083600.832091-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-24_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=970 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907240097 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). Acked-by: Kirill A. Shutemov Reviewed-by: Srikar Dronamraju Signed-off-by: Song Liu --- kernel/events/uprobes.c | 46 ++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 84fa00497c49..6b217bd031ef 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -160,16 +160,19 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, int err; struct mmu_notifier_range range; struct mem_cgroup *memcg; + bool orig = new_page->mapping != NULL; /* new_page == orig_page */ mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, mm, addr, addr + PAGE_SIZE); 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 (!orig) { + 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 +180,24 @@ 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 (!orig) + 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 (orig) { + lock_page(new_page); /* for page_add_file_rmap() */ + page_add_file_rmap(new_page, false); + unlock_page(new_page); + inc_mm_counter(mm, mm_counter_file(new_page)); + dec_mm_counter(mm, MM_ANONPAGES); + } else { + 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)); @@ -501,6 +513,24 @@ 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); + if (!is_register) { + 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)) { + put_page(new_page); + new_page = orig_page; + } else + put_page(orig_page); + } + } + ret = __replace_page(vma, vaddr, old_page, new_page); put_page(new_page); put_old: From patchwork Wed Jul 24 08:35:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11056339 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 46D4B6C5 for ; Wed, 24 Jul 2019 08:38:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 373E828689 for ; Wed, 24 Jul 2019 08:38:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2ADBE28782; Wed, 24 Jul 2019 08:38:30 +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 A749028689 for ; Wed, 24 Jul 2019 08:38:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C9DE6B0007; Wed, 24 Jul 2019 04:38:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 131D88E0002; Wed, 24 Jul 2019 04:38:24 -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 F0DF16B000A; Wed, 24 Jul 2019 04:38:23 -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 D0EA76B0007 for ; Wed, 24 Jul 2019 04:38:23 -0400 (EDT) Received: by mail-yw1-f71.google.com with SMTP id r67so33914675ywg.7 for ; Wed, 24 Jul 2019 01:38:23 -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=RBSQlFn7Qj7xbkRja9A0othvpYoee1ldgLcs+bHnwpy/Rwn32B8VaxxAMxKYzlAFbH cdccXDtRrMW6VCNNeahBf2xEtcBFgkmCak2G41h9fo0aKOMSMB60qqZ7ohOOC9PF0+UM 1be1l0xZoVkASs6urKc4Whp6SSjK/LzhzOyBVHKN3nSQmaKS48ujKA6GJ98qYEnHLVmm Gny6oB8v3xbrSYtZ6HDcmhv5vnY7z2+6lkk17dLxgmhnR9s14F5tm5O1uA4/OfXZ9evm lxdVaWLDuyCfPP8DoY7HiiE9kK96W5tebNCIxQz5qmoTln+TxM6mwtGF6XcftT5o9bbZ WyPw== X-Gm-Message-State: APjAAAW5SMDJMltgi/5mt6GnmzNHR7zLSDb42HDjQmG5kYdCWMSXrarE CmY8JIpW3JjRvW25jZeqDHz3aGXfzA6L3Jiv7SVBD+FBovpaYxblF2l/A1A1/2wguZuS/5Lhnju IiezEVHPjv3qcqnAMC5d+aJFxSWrM8HfXXEneJRFh4zIpxXT1SH9o3v26aLVePRWpqg== X-Received: by 2002:a0d:d616:: with SMTP id y22mr45354605ywd.365.1563957503544; Wed, 24 Jul 2019 01:38:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGpn2+TGvHZWnPlUM0LfVeyDx6V1Gs42YmeDN4OZyRwQHjYGfYyk5xsfnl+Fqg9TUaBj8y X-Received: by 2002:a0d:d616:: with SMTP id y22mr45354592ywd.365.1563957503038; Wed, 24 Jul 2019 01:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563957503; cv=none; d=google.com; s=arc-20160816; b=O7IayxKeSHq+Jj3UgWLuJpdH1m6QgeRW6eBQ1i3z3KhsVkgv2b3SxDTNJC8gkfyJW7 6psdMgyhud4uvQeuFV5em7mOutFmeq+n46+/538Uf/HV2ObRar4L6Vtrlscq4Qs4hROI bDKdyyOXgzX/5WfgsJ9DeqNLNfpfaGDWGYcenRWXj9eMr6ROJx+0SibHsac7PVJlyU7G oZ2D3+ROEv0q48slMdZRN+pa/5znIa/GV/qvZcLcD5gxMX6me4B5BbhNt4UR8jnlPnBf Gxpdm7iowRp7L2J6gW0732Vq0mGlAdhtF25wmw+0f9+yjGa7ERIaVUzNKdCezOSaHhrj 8OVw== 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=S3gNiM/NzRxJ2U3ebUADd8wvv+FmvlbsYT4DupuIuUd3KQpX5LPy3e90A/oeTNPTiT 2bf/e0k7Yw00wxWir3lvWFOLXyIzCZ8nJEaIid7dOz2OICCUDB11+EkQjvo6PJocyAHN XcfCqg9YgXcvfuQgttU6RQcbtRfF6Ob4A6jbRcs7JFGyRleJfW2myOh/pjaKaJZltSbQ 0CxheXFBZUl5juSFO43ilsmjFX7cPwH3hekwSGhiCdFoNrYAbDPyK6on7XlETkwCbEcY 13Ro2svQZAxesCss4V0Nqu7tCjlCg2KbTV+lO3P5JGvKrntViNCfCk9s6SWJO9s/mr3j nJxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=hrQDWBSd; spf=pass (google.com: domain of prvs=21083052e4=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=21083052e4=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 b140si16341700ywb.36.2019.07.24.01.38.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jul 2019 01:38:23 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=21083052e4=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=hrQDWBSd; spf=pass (google.com: domain of prvs=21083052e4=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=21083052e4=songliubraving@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6O8bdl1006351 for ; Wed, 24 Jul 2019 01:38:22 -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=hrQDWBSd1fkR5fAm2GFn7KYt27f37ZZyry6ErBdKmaOJjwXXEt7xd6SuTiMWII2RzYrt LO83GQx1CAu99ecFt91yVnxuGAEURJg91dr+VvZgKnpmrQkzKJbpji+bQWK+s7JJasJD dwPnjldMlzo82LPTBLRNIM8qNRDd0zvKCIU= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2txk7904en-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 24 Jul 2019 01:38:22 -0700 Received: from mx-out.facebook.com (2620:10d:c081:10::13) by mail.thefacebook.com (2620:10d:c081:35::129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1713.5; Wed, 24 Jul 2019 01:38:16 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id B1F6F62E30E0; Wed, 24 Jul 2019 01:36:13 -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 v8 3/4] mm, thp: introduce FOLL_SPLIT_PMD Date: Wed, 24 Jul 2019 01:35:59 -0700 Message-ID: <20190724083600.832091-4-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190724083600.832091-1-songliubraving@fb.com> References: <20190724083600.832091-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-24_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-1907240097 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 Wed Jul 24 08:36:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11056333 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 D0E9D6C5 for ; Wed, 24 Jul 2019 08:38:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE9FD28732 for ; Wed, 24 Jul 2019 08:38:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE34F28689; Wed, 24 Jul 2019 08:38:22 +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 3449828689 for ; Wed, 24 Jul 2019 08:38:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 374D06B0003; Wed, 24 Jul 2019 04:38:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 324946B0006; Wed, 24 Jul 2019 04:38:21 -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 1ED9C8E0002; Wed, 24 Jul 2019 04:38:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id D91276B0003 for ; Wed, 24 Jul 2019 04:38:20 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id x10so28091936pfa.23 for ; Wed, 24 Jul 2019 01:38:20 -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=fdQGaz4EpVqsr8IruEHXBQPn+tzS7bteUBGGvvH6wDw=; b=JAvi1VtSgx4GqjUvc/EY5MlRMKqUmos6squy0b4DAhTupVj3t22QGqtjB5fK1UbOZR 4uXrCb66AKcgVXWQ5pK1O+jSeS83/VxGsmgSDBOEMJDHKfg15zjNsH25lezsKL6SvuuL Pwxsd7YOTqfR+D4hGfZ//aCuuzxTS3SGGFhyHdxJBhs4mCCCXJ2tw10glPPZfUxQa24M yp5/BCN6Sv1fKDbNCTu/XLe8IKUUrjWIf9t4V5LHOYjrkOlaz0IEn/V2w5HOjBOEilL5 DFnY82hcHAHUVGnn/6NAjFgsrBvHBsTsPKSw5MeaC0rfeZJrdeYRV4oVNVxGqIqKGeLt HX2w== X-Gm-Message-State: APjAAAXRiXHJ14TXgpoodFT3ptr+5fglh/TvrnSeqMp990g0BCBt4OyT CNTBXVAuJAdJOhYYo+p1T9hYHnyOKLoq2YIAeK5Bm4sx/WMOIuJNTQ9ucCJOB3TMgqnVpsi5CTi HJm1QrKZFgmwHmuN3kc1QgoCbjNZc8x6dDAuomOF3ktCtm+/J44p4E8Bn59hE4InWKQ== X-Received: by 2002:a17:902:9a06:: with SMTP id v6mr82602508plp.71.1563957500557; Wed, 24 Jul 2019 01:38:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxW9FuzXflYZUx/WdyFwCI6LylBSQR9iLUXdZnH/Y3BNPX5FtlVXpZy7Tx3MvPigcmvuSBH X-Received: by 2002:a17:902:9a06:: with SMTP id v6mr82602488plp.71.1563957499930; Wed, 24 Jul 2019 01:38:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563957499; cv=none; d=google.com; s=arc-20160816; b=UWnd421nmok2yOWMebOg/+EijNO2lK3O1lu9JjzJCrrS0Rk8nkmddgHNZkvXoq4tlY E3cu6OVA+kY1YjZxq8Jfpd1EguuP7SyIlDx5FloLzCnQhcXn0LKU1qhApZVHJeo3Nl/I A1mmjLwoVJdZFkYX2UEJkwoI/wCxyQQxX1HPZJH+te8kOwV+nRNXqDyNJC2KPmwNnpLn iZCWSA/bTuCxk2D52hffMv6nzlkxX2t9CiH1Lcz0h/gGDzSwgi84BJb+jWgdesCJy1Ip oxHt2t6p680+8Ud/qXhvf4YeyFKsTMAIH3hG1H0Dz51U5kdA93QpSDEV9Jl/twU3rPpN e9WA== 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=fdQGaz4EpVqsr8IruEHXBQPn+tzS7bteUBGGvvH6wDw=; b=P2kZywqmYgkahfh/kUFq7NPtuXILepVD213qEZcjuBZif1A/PyWySfzoD2RAkdZnbx vtsmI5askjXDBlYaEefanMi9AX18eOcQ6HxcobmYpGQvQsdWhnCA08yXZw5zurDaPLWS EUjAAT6/oebGXqvyvakN7V/keDig4dEYJQi1iwalAX+Gzt1yeTN7hFqZXINN19yuxtRE zjhha1QW7yOB7dNt3FV9RcQlZkeREveL8HDCfzmFyefmjB48kTHWJug6xh2cVr7+4fzg UH+ggtUriMpk9q50FQtHHW4tX4BkVek/C8gGt2EJQm7fbpbm5oG9JFWIfMoDEVN9m10z pkPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b="OBXaf/q6"; spf=pass (google.com: domain of prvs=21083052e4=songliubraving@fb.com designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=21083052e4=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 a130si3970828pfa.7.2019.07.24.01.38.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jul 2019 01:38:19 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=21083052e4=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="OBXaf/q6"; spf=pass (google.com: domain of prvs=21083052e4=songliubraving@fb.com designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=21083052e4=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 x6O8c5Eb009731 for ; Wed, 24 Jul 2019 01:38:19 -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=fdQGaz4EpVqsr8IruEHXBQPn+tzS7bteUBGGvvH6wDw=; b=OBXaf/q6D1hNWZZGG0d+m/rm3OiMOOzTivGKKNrE0restt7dQZpVq/YGozpXbGewSArm DlJr4i48mhMlIQHUjqBsZZsmYHwf40EarudAi1I54FBazlFqjqbf+2XTpz+R6DiVsf67 r3ZNPh/bGCIOcFnZtoad9xxxTKOPxVX4oVc= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 2txcwahabe-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 24 Jul 2019 01:38:19 -0700 Received: from mx-out.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 24 Jul 2019 01:38:17 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id 1A04B62E30E3; Wed, 24 Jul 2019 01:36:15 -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 v8 4/4] uprobe: use FOLL_SPLIT_PMD instead of FOLL_SPLIT Date: Wed, 24 Jul 2019 01:36:00 -0700 Message-ID: <20190724083600.832091-5-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190724083600.832091-1-songliubraving@fb.com> References: <20190724083600.832091-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-24_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=744 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907240097 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 --- 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 6b217bd031ef..7d11ea16d471 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -153,7 +153,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, }; @@ -165,8 +165,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 (!orig) { err = mem_cgroup_try_charge(new_page, vma->vm_mm, GFP_KERNEL, &memcg, false); @@ -483,7 +481,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;