From patchwork Tue Jun 25 23:53:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11016605 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 BAE66924 for ; Tue, 25 Jun 2019 23:53:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9F1328553 for ; Tue, 25 Jun 2019 23:53:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E0E2285BE; Tue, 25 Jun 2019 23:53:40 +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 64E3728553 for ; Tue, 25 Jun 2019 23:53:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A7F36B0003; Tue, 25 Jun 2019 19:53:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 17E6C8E0005; Tue, 25 Jun 2019 19:53:36 -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 EA0EE6B0007; Tue, 25 Jun 2019 19:53:35 -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 C7BA26B0006 for ; Tue, 25 Jun 2019 19:53:35 -0400 (EDT) Received: by mail-yw1-f72.google.com with SMTP id j124so1066361ywf.11 for ; Tue, 25 Jun 2019 16:53:35 -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=WYZxiREwAeaU2t88V8DNSwbVqkRoedXJSQJxp8fHgHM=; b=ozM0IbJcJp5hebPt832o23w+JdUGcKHSfnBuCJDzUNYNM+hkeWSaKYOjj8q4tkNAcv tplLX5saaWXJSLY+y+4BwsaWOI8h+ycI5pTfOHa96UID+rIcZJqqdNbjQMwiREWKd+qZ YrKL319YmoT9f7rojg1jrkSfqy0YX7ks6uHgTrNekHP04YjBmIpKIL4lChcuLtjA1Kdb rWhDGCmIVNBqD3IxIyRfTBoCkOm5ZWYu3PkU+9gK96qRP1eVY1RJruylr/OygaW/qjSG 11NwHMDjk8wVFpKBurjQOqDehFKXqderbN5RkWYVENtcYeRXpwYDPbjFfgXi8aNaVxEo M0BQ== X-Gm-Message-State: APjAAAXPi/MVcomjriAv3vRTvq6JC/NX3boxvEsZw8Oud4+3NTOMWmn9 FmqWN1CHZ5JGbF6vvE7NNSPzTF4gggUUfb+ph5uYtp1JZtTb8+OJNS+KcgGDt+pATB+AP/rP4H6 WwgNYcdQDqWzWTFzrSrEoWXhwamfePgxnfBGJfGkGEwYXdun7BJOkOtUfGAmXtlrbZg== X-Received: by 2002:a25:d856:: with SMTP id p83mr759736ybg.434.1561506815514; Tue, 25 Jun 2019 16:53:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHOGyj8dot8ErJOzbp6nWzMxQMHPurSD26yWyU5yp1ur55qHQuMqcpcvRf5jU5tXOuPRyS X-Received: by 2002:a25:d856:: with SMTP id p83mr759716ybg.434.1561506814914; Tue, 25 Jun 2019 16:53:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561506814; cv=none; d=google.com; s=arc-20160816; b=I1Ouh/w2WAscbvlxQ0POms587VOVMherVm09co5DmI/waiSAqaNUU7Y9jgh1sTx44u DQXQ9h7PLnkSpzZ6mFxjnPuMvAiLxjSfk5FawHoKFqDE1/Yab+2LAxAWe3jxgjJGENcz Vvyp595QijgF34/WDBrDh8U76xpviLOB6bZd6ViTj25W5AdVNfvL7R1IAHCPsgQyAFUz fe5W0P7iICd5shOgMBiWy++t912JvFAICY6zl77lNWr5P7XIF0QQGcBVgCVkhqC+4vs1 raGX/BrcbBfleHLIJ1TtIyTjUf15HMjGCr12hptg+EO8PlMdf5Tv3sbWKZqtBIwY9aWR xMdQ== 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=WYZxiREwAeaU2t88V8DNSwbVqkRoedXJSQJxp8fHgHM=; b=N5lZ7NuOmP8ymZj41Q7r8io3pvg5rV7KMLjqGaBXSlTJMMEggJzxjkzyGCNyGTlH5M 0QuikVy/friFJ88y0OIq2vpG/h2HHSKvdNgWcjF5th9Ph8PNgIDBEYjpTVTkf+SfZg1Y 95ot66Mj+8OxRTpFbE89fP5hMT0AcjL/fGroLNZq4KoiA1u7NLADNYpgWMJrSnBVs7vO j0ZqH+ALVVW6zOQ5KKrFNz61iBNUjyUO5g32AlrJrXcM100UbncXo+b7ZKiwFPS5L2tQ 8Y0h4KPXBFLw/BKmVVgpQh8rRVAzSXGyBs9+QnHEPlFftfpawQuyV2H0Qrfwfho06LnX gZsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=g8AnEw7N; spf=pass (google.com: domain of prvs=1079b839a8=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=1079b839a8=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 138si5787806ywq.162.2019.06.25.16.53.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jun 2019 16:53:34 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=1079b839a8=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=g8AnEw7N; spf=pass (google.com: domain of prvs=1079b839a8=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=1079b839a8=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 x5PNqZpk032119 for ; Tue, 25 Jun 2019 16:53:34 -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=WYZxiREwAeaU2t88V8DNSwbVqkRoedXJSQJxp8fHgHM=; b=g8AnEw7Nee6zUOfEHaIFdF2U2Apd6FhKQ98r8Kaqs7LYcIqS0iTu7YVgVMd95RvucnAy gi6OLa9EEizO+f1oGGM3yP8Yp7HysNFeaR5vJy9l3GLH44rrTqS48GhA/pu/DL85W6Uv XSxmFIwEQevIYRJmNQ2BsTBt9fUDhLOk85M= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0001303.ppops.net with ESMTP id 2tbpv81mvh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 25 Jun 2019 16:53:34 -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; Tue, 25 Jun 2019 16:53:33 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id 4223262E1F8B; Tue, 25 Jun 2019 16:53:33 -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 v7 1/4] mm: move memcmp_pages() and pages_identical() Date: Tue, 25 Jun 2019 16:53:22 -0700 Message-ID: <20190625235325.2096441-2-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190625235325.2096441-1-songliubraving@fb.com> References: <20190625235325.2096441-1-songliubraving@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-25_16:,, 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=986 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906250196 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 dd0b5f4e1e45..0ab8c7d84cd0 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 9834c4ab7d8e..750e586d50bc 100644 --- a/mm/util.c +++ b/mm/util.c @@ -755,3 +755,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 Tue Jun 25 23:53:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11016607 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 A7484924 for ; Tue, 25 Jun 2019 23:53:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96A4828553 for ; Tue, 25 Jun 2019 23:53:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8ABB0285BE; Tue, 25 Jun 2019 23:53:42 +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 08A2528553 for ; Tue, 25 Jun 2019 23:53:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 774698E0005; Tue, 25 Jun 2019 19:53:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6FDDB8E0003; Tue, 25 Jun 2019 19:53:37 -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 579968E0005; Tue, 25 Jun 2019 19:53:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by kanga.kvack.org (Postfix) with ESMTP id 2D2D28E0003 for ; Tue, 25 Jun 2019 19:53:37 -0400 (EDT) Received: by mail-yb1-f198.google.com with SMTP id u9so1499441ybb.14 for ; Tue, 25 Jun 2019 16:53:37 -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=YzvayIkmd6XFy7Z87fb6rHJsaY4AzAfNVKftttxQWf8=; b=EJ5XhjT6ND+fUjP2cMPpLKwfmCLSBNM5CU+RFLTqphubLibqKk1yBdZ0kKZpVHh+FQ 7lxTVzEOGeSfl2W62zTTu10I07aRpDnl07+AgiX8H1HAzzuDxjm/3VZzdRAkgTwz6ZPJ cJ5ZObCJY3/hFFATAcnHhSO3qUoR+R+yEr8eyTFgtxlEdLMEZlSZ5730tWmSB0PkASa9 bvrBAA1Oq5oDhhQG/uy/hbvMEzrBbVsJuslmxjSTGPDfJLFXlVaK7TwbgG6j/l7wVcDC AUnbu8YqEmfy/xE2fluKEYV1RFWHTagtNeETCDB6HDx1YiBHtnwTtAq7efZl4238l+Ss S9mQ== X-Gm-Message-State: APjAAAW/NECB75ppQfeYFUQIXUSXcqX4etMT/uAKZxvNsd25BarSjoUC m5Glhwmwkswvf4dsyjEk0/9bhGoVOHQc9R0NJMhI1yf3o6j2BruvwZj3g7hO7Fp6quqNRTELtq8 kf3m3Ev71hjuwthtIwlkxC/KoHv6SdHgChRx/4aqxucgt2m/h7KSqLFygitSxuKUJEw== X-Received: by 2002:a81:6082:: with SMTP id u124mr940757ywb.241.1561506816981; Tue, 25 Jun 2019 16:53:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzM4kfLnDKHmszK4Tp3bZDDPe3amNZWKaDjVg9s6wX0KJPtCE8ErPCvM+DmrQQNLqogso45 X-Received: by 2002:a81:6082:: with SMTP id u124mr940741ywb.241.1561506816455; Tue, 25 Jun 2019 16:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561506816; cv=none; d=google.com; s=arc-20160816; b=yF/m69YG/L61UKZJyEizQbcBGYpGjLsFYNYdrftK0PPK9UfewADM1RmIgvf5L2jDRd X5Qgx6yXGZnXVDVMNgKlM+A5loB0exMBQ3FZKttOpeG7aZmpofK5I87sB0rKNao9xnYF uhsJVLRVfPe5PzWnmTZQlEPgMhj91f7Inz8FjKqCSsabO6AfUOQai1kXnmupmr6EeIuF v/8djaE2dBexJsHgik+uHe0ErEX6IQfANRCC+hSADn2McgJBKPOZ7MPvacyHBz2POvZj keNjDXccueh+2nWMxaP8vHuKAWUeJZk4FejwJNocQl/4HGGjEKjQ6gJrW0JY3Blp1pCb pDfg== 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=YzvayIkmd6XFy7Z87fb6rHJsaY4AzAfNVKftttxQWf8=; b=WWaD2/ziW1qYVmY4PiFVHARIr3xOM5dLx5JVtcEJ826sDu8bCupDppFAEe5KlzoRfN 3e2iR/XBZjXFkPGgV5bnYSRsmlAmaLG1eCl3pKWLG0LMlw3sC8u4EWWqlKK30GenILMz YMNFyzM/49X7sVU1AFjNqCEnZ2CaBxqWhC+e/KENS8UOFRoegFuGJpitSPNv4V+nA//W Mt6HLOuh/wUJ/MzBpkswNwK5jUw0WxC1fVNecPRVaH8hQkQ0qu57yWea0NMBnXLWaZLg hW8S8UmOR1F9Ue2xW6efo93Eq1yzH24O91UhPhsmmvkzGGA24Qsm+MUf36BAXZRA6CXL e4bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=RtFUfJbt; spf=pass (google.com: domain of prvs=1079b839a8=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=1079b839a8=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 y16si5549304ybg.452.2019.06.25.16.53.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jun 2019 16:53:36 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=1079b839a8=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=RtFUfJbt; spf=pass (google.com: domain of prvs=1079b839a8=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=1079b839a8=songliubraving@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5PNqLO5027784 for ; Tue, 25 Jun 2019 16:53:36 -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=YzvayIkmd6XFy7Z87fb6rHJsaY4AzAfNVKftttxQWf8=; b=RtFUfJbt1MHzqzGshzQevaSsS2nNZVwt0uHkXeJMVYRCMDWfT9/sHO4ZkpKJErfWounv rM3hcwLXV41yESC+6Al8uHVRA2kz7lhWvvuV13Gr9e3xWFf8bzvlsc7uhDYkH8tw0wjq nWZ/PHEQqcdCOkQq3rYX/anPuq8acBF39ZQ= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0b-00082601.pphosted.com with ESMTP id 2tbqn21enk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 25 Jun 2019 16:53:36 -0700 Received: from mx-out.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::f) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 25 Jun 2019 16:53:35 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id BCEF762E1F8B; Tue, 25 Jun 2019 16:53:34 -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 v7 2/4] uprobe: use original page when all uprobes are removed Date: Tue, 25 Jun 2019 16:53:23 -0700 Message-ID: <20190625235325.2096441-3-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190625235325.2096441-1-songliubraving@fb.com> References: <20190625235325.2096441-1-songliubraving@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-25_16:,, 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906250196 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 Signed-off-by: Song Liu Reviewed-by: Srikar Dronamraju --- kernel/events/uprobes.c | 45 +++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 78f61bfc6b79..f7c61a1ef720 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,23 @@ 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 (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 Tue Jun 25 23:53:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11016609 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 6BCFB14BB for ; Tue, 25 Jun 2019 23:53:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C10728553 for ; Tue, 25 Jun 2019 23:53:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5003E285BE; Tue, 25 Jun 2019 23:53:45 +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 C71B228553 for ; Tue, 25 Jun 2019 23:53:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC7658E0006; Tue, 25 Jun 2019 19:53:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E7AB48E0003; Tue, 25 Jun 2019 19:53: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 D1B1F8E0006; Tue, 25 Jun 2019 19:53:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by kanga.kvack.org (Postfix) with ESMTP id AE5508E0003 for ; Tue, 25 Jun 2019 19:53:40 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id a4so952450ybl.9 for ; Tue, 25 Jun 2019 16:53:40 -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=5x4CyyHGkS8Ksf2g8Si1t+/7cLJQzDvLwXFviKMvEaw=; b=F424RyBpP9n+873qBvDl10Gu75tDBmhoqCiRkeOqymYAIy5mwHYDMzh7Ns3rt9NMBI b3Bpwlgk9MbD7pZ4pvN8HVJfiArRKrhchFWjMnpOSNnl6fwzhMmLL0z21Nmu1FUcPL9k HlYq/Ae2mgECur/wJGuiT7l1HeoziRt72Wql/s/3Nb96TSzMbLvkyFyoi+TvDiU/GAmf 3XZCnzX+nc6epJJhXby80XS0aopzQjl2AlNSwKp4f8v7i4eTngEiNCrswFZWzOjulgjM mm0ir0z6wB8AAMtHFSK4oTMyX7AiWGeEDSAto797jyibRW2feWr147HNToqBSstE8x4S v64Q== X-Gm-Message-State: APjAAAXKkTs9pYYXPIP+J4qUwr/gEC17eAqfKigv1EO4YxiN5TDJKVHX 4o/eqVO04LeEmSFbRNamDajC9X5J9JXVIwX/GBWODA7P2+5RZc/MxCALLXS4CpasJxoDtteoezF nBCJ0OYOz8UOCWL4Yt3PXqQmZCCCy1WR++Ss5MHB+qr3QmHVg+jVemAPLJ3U7j/onSA== X-Received: by 2002:a25:ef02:: with SMTP id g2mr778920ybd.271.1561506820498; Tue, 25 Jun 2019 16:53:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvwwr38iID+1XC3iYZsuhinb7BerPMLRSn7IH+jp2hIM4YFioWZU7lazWMehonkcttif6+ X-Received: by 2002:a25:ef02:: with SMTP id g2mr778898ybd.271.1561506819966; Tue, 25 Jun 2019 16:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561506819; cv=none; d=google.com; s=arc-20160816; b=b6pU4aE/P/EHbf/z8lXJXGFhu0jgsR0oK4mtU2+dwYJ2fhn2ifJkb9k3tICU4QMSi/ EVlxCqo1EZSpeR3oTJjB6eG2qJoyDQfhU4lLBpI973b+Kej2Ob8ZR5zIUhgkWIwZ3EJn 0UMrveykSfRQPe8KVk8hqLf2LdLCAmRxHtCxwqn7H5kQaCsrmlglqLqhlSm2w0U6lecc sdku2pmciAsesSRTRC9T4Z7UWcxuCtwm9l+xjYWrY/tPRylB/+tVMyw7bCMF/Xe43Xl9 lT8vLVTp3tsdKn4C9cxMRrzP0k0JCdpPAyi8zFkpaw1wdOfArsW6tnLaA4J7orEHaxHN WS9w== 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=5x4CyyHGkS8Ksf2g8Si1t+/7cLJQzDvLwXFviKMvEaw=; b=HRZ6CoUhgkCC2gV5edfs0oog1OzfJT6WKjvg9G2l3IWxG/0028QR4zqWcoPGeUW5Qa c9zIKXkNfUBRivCvv5z+I48eq9XEbZYFfBphNXrAaYoFJUZa+oArxQL5fyr16nxzSVL8 w5e0c1wa0aNoqz3VdE2AiwLTSydZJwbiAe8E7t6UzkyHHRWdQ8pX6rUUbI3jfTLrSb/4 gsqkJHgwDtGlRCYX1DKwgMRly77L/TyG6KJ/16Dj8DirnOGDEKS+SjXi+4UMl9I8vPL0 pbXYibDauVtLxIGC3TiI+hHapKMgShY7npFV9eLJLmx1hAcq9FWYJeUHIyA7rsgePLtB gJZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=MWRRYvz7; spf=pass (google.com: domain of prvs=1079b839a8=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=1079b839a8=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 f3si5769952ybh.294.2019.06.25.16.53.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jun 2019 16:53:39 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=1079b839a8=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=MWRRYvz7; spf=pass (google.com: domain of prvs=1079b839a8=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=1079b839a8=songliubraving@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.27/8.16.0.27) with SMTP id x5PNmm4Q020396 for ; Tue, 25 Jun 2019 16:53:39 -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=5x4CyyHGkS8Ksf2g8Si1t+/7cLJQzDvLwXFviKMvEaw=; b=MWRRYvz78FvcXt3p58yon+68zcAGBYbbqkDqwzq3CTgaVw4O4/WrH/0LIH/ZunYkOzLg yCx2yY7bl3vWPctIAaQcM+7xH75fPXzuJG+nTmgrdGNug5ysJrKsKPWBkHIrcp8CYHf1 uJLgDDCDTBkhppBR9bOVOletyXXLqltJJCQ= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net with ESMTP id 2tbsw3gux4-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 25 Jun 2019 16:53:39 -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; Tue, 25 Jun 2019 16:53:38 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id 4882662E1F8B; Tue, 25 Jun 2019 16:53:37 -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 v7 3/4] mm, thp: introduce FOLL_SPLIT_PMD Date: Tue, 25 Jun 2019 16:53:24 -0700 Message-ID: <20190625235325.2096441-4-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190625235325.2096441-1-songliubraving@fb.com> References: <20190625235325.2096441-1-songliubraving@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-25_16:,, 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-1810050000 definitions=main-1906250196 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 0ab8c7d84cd0..e605acc4fc81 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2642,6 +2642,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 ddde097cf9e4..41f2a1fcc6f0 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -398,7 +398,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)) { @@ -407,7 +407,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); @@ -419,6 +419,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 Tue Jun 25 23:53:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11016611 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 1FB03924 for ; Tue, 25 Jun 2019 23:53:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 105C128553 for ; Tue, 25 Jun 2019 23:53:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02104285BE; Tue, 25 Jun 2019 23:53:47 +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 81FE128553 for ; Tue, 25 Jun 2019 23:53:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF9028E0007; Tue, 25 Jun 2019 19:53:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AA8718E0003; Tue, 25 Jun 2019 19:53: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 9494A8E0007; Tue, 25 Jun 2019 19:53:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f69.google.com (mail-yw1-f69.google.com [209.85.161.69]) by kanga.kvack.org (Postfix) with ESMTP id 729C78E0003 for ; Tue, 25 Jun 2019 19:53:42 -0400 (EDT) Received: by mail-yw1-f69.google.com with SMTP id k10so1033021ywb.18 for ; Tue, 25 Jun 2019 16:53:42 -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=yjZXcMnfv52cV3iKAqHjSpI81GHA3MMnQyOdI5uEAgE=; b=DvJiSokM9IXl2IqgFtxXy7O+EUQgcD4y5mgxyQzb8cCdtlmtsLTZj2Vnm87qkQpV8S qIOibwuv4PqUNHDu29jnP3q0amzr+mKx/QIxHvIyzDpX5nij0oWwky20ZaWrwoAhLRem Fo8pBrDQAGwAfd4NzV/nhICcvaikmrMnq75fbZyGkSdYZzoy3GycyHAkNI5OKyYGTEtQ aO+HHk9KXJjfbwrrkIqADQyiUqprP7b8smc6xxdkvUprwuGNHfnNI87Er3/XcesAFuhU IcJjyaVpnUGFH2tbnQ/Y3P0fgpAayBsOouXQrVEh7Q6epLsYWtxWHR3Mjd51ud+zHoPj JpUQ== X-Gm-Message-State: APjAAAWbebMYRcoFl7CqDyteI3dlZZ8HlZA66WCUiPZowlaieaiC0dUE XN2HIB764Fe0HRCnD1x7kQaRUs71ytc8bQMR2xJael1Iwqxl5VoQLoJZ1p9Pj1yQj3eMovTyIsf E1mSlmF3SMoSxuA+DYZG/vmorP1dMeLOHSHBTM+4N1YufC3YSgmxFoWrlKAEqcQ0ocA== X-Received: by 2002:a81:23ca:: with SMTP id j193mr928347ywj.332.1561506822184; Tue, 25 Jun 2019 16:53:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqydwtqjeI66/K9JNQwFWE98bfCPnt8xGURaejJfO4pVIsvKR4KWbn4u2WhJLMxIHop51GHV X-Received: by 2002:a81:23ca:: with SMTP id j193mr928327ywj.332.1561506821560; Tue, 25 Jun 2019 16:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561506821; cv=none; d=google.com; s=arc-20160816; b=BTxzs1rBUJmu0bhDd8jRz/PMgiBlZUWCyPRLP9pcsAh/CS8Na4aMrQLVEb7Nr+oy2j kjPAUtRxTdZIRkv6d0V43p0xcLS7JY3XGptOpH4Q7RND4AqPWklvQ0gTqiGUgh44z0NS Syp/+sFmEIGzpU3FIiofx3S66m6nFKn0TeUSS0LPFQg8CM+vesDumdn0ySjGYNPo+8RW UGzuYWCPqH0pGa+H2+/RHYbCsrAodaHI5oQ8oRaJJRoYxmWVie4ofxjUH2NpvuHBMW/0 vKiIJuXa/Tdny5EkxAfybr6NZLxusv0yv92KSkusUIEGHWp62nSlAFRzB97Wo6wQeZWe 9Q4g== 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=yjZXcMnfv52cV3iKAqHjSpI81GHA3MMnQyOdI5uEAgE=; b=ZRYO/zcDPtGNzLeXlU+MvkDPZCGLtMAlZUrWpXdmh5ik81xZtO9KKBU4yag7TEzWKP esbpBamUj7TDNPYGmSnsNoSpRNP1OGyPSjPMZSct8OhVd1m0PbgebAb2eaLpLI4Lg4Ty CfS7jW/hKg47sLzim1zWBYXPSnW7DUKIPJ0VzmlAzf1HYBvzP1Ic5V0/7DUWsojo8sdW j/J+HSD54LRueXgf117mvYdV0csMY3CQv0GUQGGHJrHwdcl4DKaokAeG9AboYeNlnq3r GCLvkIJ2GPlvCapwQ5efm6v1k+DfWMZv0P1VDXA+WMMBPU9F7rrFgQnVDsyGkTVAX7Jk XCkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=VkTn5AAk; spf=pass (google.com: domain of prvs=1079b839a8=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=1079b839a8=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 h3si2417349ybo.307.2019.06.25.16.53.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jun 2019 16:53:41 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=1079b839a8=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=VkTn5AAk; spf=pass (google.com: domain of prvs=1079b839a8=songliubraving@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=1079b839a8=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 x5PNm1ef020477 for ; Tue, 25 Jun 2019 16:53:41 -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=yjZXcMnfv52cV3iKAqHjSpI81GHA3MMnQyOdI5uEAgE=; b=VkTn5AAkF2g/g6aMB4uoEcacFi6ioIEc0jHI+HVDO8/jXANbk9TQoPd/wTj8QI8dmV1v 8oyl60BTncgPcmOw6/culgQ4kWqb1/6sgqTOldJJH4RSV4AT1ZFXmqoz2L0eExf8jbZ+ Nw3kRVNGo3y5+heuWvOFhqIgFAE4Q3jtu7A= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2tbrn7958t-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 25 Jun 2019 16:53:41 -0700 Received: from mx-out.facebook.com (2620:10d:c081:10::13) by mail.thefacebook.com (2620:10d:c081:35::125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1713.5; Tue, 25 Jun 2019 16:53:40 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id D10D962E1F8B; Tue, 25 Jun 2019 16:53:38 -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 v7 4/4] uprobe: use FOLL_SPLIT_PMD instead of FOLL_SPLIT Date: Tue, 25 Jun 2019 16:53:25 -0700 Message-ID: <20190625235325.2096441-5-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190625235325.2096441-1-songliubraving@fb.com> References: <20190625235325.2096441-1-songliubraving@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-25_16:,, 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=729 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906250195 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 Signed-off-by: Song Liu Reviewed-by: Srikar Dronamraju --- 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 f7c61a1ef720..a20d7b43a056 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;