Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp25332ybi; Thu, 13 Jun 2019 10:59:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBWk655iSBitrH8xhu+W9jxr9/Y8wkEnN4Rf62A0qiWBE3jeMjNP3lTzt4HuXI44eOCt0k X-Received: by 2002:a63:d008:: with SMTP id z8mr32106629pgf.335.1560448778657; Thu, 13 Jun 2019 10:59:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560448778; cv=none; d=google.com; s=arc-20160816; b=XRGOWhZ5OTzc3BMaUIw+LJml1k54TV2hMbTwu9Kdi2/eHZrSv/6p5UIOke2TPqZoHD iI4BazsK9y5w9T/pw8LvewvBjMzU+XeEo/cZtdX8+vwBR/fERVKfEehHFdUCi+e/YgR2 4doIJaPL7GSgYVlnqGujNpD8J95J4yzmF+eKIx/TXUQC5zRabqxWc56jrw2B0biD7N36 /1Ipr3Z0/rNrGB3ODYQ0Fq8DOBxRM8EEudhHjFA3KOoMikQqnJfxPBxCgEMijo5RQJjY Y3J7zwSY7NtI4W/CjkIT0iFDbiEP+xSYh7Edj5V2k29lPdOg04Xiiu1HS8y4RoeLYSQt RKVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject :smtp-origin-cluster:cc:to:smtp-origin-hostname:from :smtp-origin-hostprefix:dkim-signature; bh=SN9bJYBvVZmjIY7TQwW3dcHWX2b73J5/DqqXtyPOt5g=; b=Cvkj7VrrBfvYcCXM5fPxHPwE4rigUWB3b1pk47xqzlxky6maruGe3A7yggx7tKoymf NGa904nO8cijih4T0vyd5uHaOPVkMnyOnrqkRe6L0+P+KWuYnyBnfRArH64J3hNSmHma r/VJCRlJ/7GK/7Tid6lbh7lt2+JUH13mv1FJWYzpNw3gv8QtvrsG+ek0uObmUcA8pPfr L9BCq1U6n+v8VZ06viuHVL+axaeCY2WYhPwbb70iie9TUeS85i8a9CETFvZKwpgJOaWB 9MGaSCUVWCDt5n8QnImdEEiFPpBxJmorQAOpTFJ5Igt8KZ1vo2k1skoYlz8F8Y6V/GGN jKUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=PfQXkQIX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7si233349pfp.4.2019.06.13.10.59.23; Thu, 13 Jun 2019 10:59:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=PfQXkQIX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727656AbfFMR6A (ORCPT + 99 others); Thu, 13 Jun 2019 13:58:00 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:33022 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727158AbfFMR57 (ORCPT ); Thu, 13 Jun 2019 13:57:59 -0400 Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5DHpnxo001518 for ; Thu, 13 Jun 2019 10:57:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=SN9bJYBvVZmjIY7TQwW3dcHWX2b73J5/DqqXtyPOt5g=; b=PfQXkQIXJKJYZzYLK2K6BK+Mcwkf22sy+R8ogNnL5euBKlXTZdZh6uBUfvrIEjf6xLFF jBqMf2Z3I1TEuaNXdU2U6zAW5c7JfcRtkGEU3aZPsWh3woDfucKpJpSHzuDh/YJuq99C u6HPiugIHARcUnKwy8BwfvqMgpFVL2Xf2eE= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 2t3py212uu-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 13 Jun 2019 10:57:58 -0700 Received: from mx-out.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 13 Jun 2019 10:57:55 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id 3DA8762E1C18; Thu, 13 Jun 2019 10:57:55 -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 v4 0/5] THP aware uprobe Date: Thu, 13 Jun 2019 10:57:42 -0700 Message-ID: <20190613175747.1964753-1-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-13_12:,, 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-1906130131 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This set makes uprobe aware of THPs. Currently, when uprobe is attached to text on THP, the page is split by FOLL_SPLIT. As a result, uprobe eliminates the performance benefit of THP. This set makes uprobe THP-aware. Instead of FOLL_SPLIT, we introduces FOLL_SPLIT_PMD, which only split PMD for uprobe. After all uprobes within the THP are removed, the PTEs are regrouped into huge PMD. Note that, with uprobes attached, the process runs with PTEs for the huge page. The performance benefit of THP is recovered _after_ all uprobes on the huge page are detached. This set (plus a few THP patches) is also available at https://github.com/liu-song-6/linux/tree/uprobe-thp Changes since v3: 1. Simplify FOLL_SPLIT_PMD case in follow_pmd_mask(), (Kirill A. Shutemov) 2. Fix try_collapse_huge_pmd() to match change in follow_pmd_mask(). Changes since v2: 1. For FOLL_SPLIT_PMD, populated the page table in follow_pmd_mask(). 2. Simplify logic in uprobe_write_opcode. (Oleg Nesterov) 3. Fix page refcount handling with FOLL_SPLIT_PMD. 4. Much more testing, together with THP on ext4 and btrfs (sending in separate set). 5. Rebased up on Linus's tree: commit 35110e38e6c5 ("Merge tag 'media/v5.2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media") Changes since v1: 1. introduces FOLL_SPLIT_PMD, instead of modifying split_huge_pmd*(); 2. reuse pages_identical() from ksm.c; 3. rewrite most of try_collapse_huge_pmd(). Song Liu (5): mm: move memcmp_pages() and pages_identical() uprobe: use original page when all uprobes are removed mm, thp: introduce FOLL_SPLIT_PMD uprobe: use FOLL_SPLIT_PMD instead of FOLL_SPLIT uprobe: collapse THP pmd after removing all uprobes include/linux/huge_mm.h | 7 +++++ include/linux/mm.h | 8 +++++ kernel/events/uprobes.c | 54 +++++++++++++++++++++++++------- mm/gup.c | 9 ++++-- mm/huge_memory.c | 69 +++++++++++++++++++++++++++++++++++++++++ mm/ksm.c | 18 ----------- mm/util.c | 13 ++++++++ 7 files changed, 146 insertions(+), 32 deletions(-) -- 2.17.1