From patchwork Thu Feb 4 20:24:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12068619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27054C433DB for ; Thu, 4 Feb 2021 20:25:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8B7AA64E0A for ; Thu, 4 Feb 2021 20:25:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B7AA64E0A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 112746B0070; Thu, 4 Feb 2021 15:25:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0CC726B0005; Thu, 4 Feb 2021 15:25:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3D2B6B0005; Thu, 4 Feb 2021 15:25:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0084.hostedemail.com [216.40.44.84]) by kanga.kvack.org (Postfix) with ESMTP id C6D236B0005 for ; Thu, 4 Feb 2021 15:25:17 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 947A23637 for ; Thu, 4 Feb 2021 20:25:17 +0000 (UTC) X-FDA: 77781715074.26.nail53_2f02cd4275df Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 59FA11804B667 for ; Thu, 4 Feb 2021 20:25:17 +0000 (UTC) X-HE-Tag: nail53_2f02cd4275df X-Filterd-Recvd-Size: 12371 Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Feb 2021 20:25:16 +0000 (UTC) Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114KK2Ij136559; Thu, 4 Feb 2021 20:25:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-type : mime-version; s=corp-2020-01-29; bh=z8XNkIOJB3++sM2ChemHCEjB8h4QyKCc45ubyIZXMlI=; b=SDPprUl+6GoJGETxm8v5Ow9fL9U/vndE2p2lRaaiGbd7Q2KL1PWrbO/BKPPQoaJH4tFE GQkbizq72nzC34PttGepfEGN94Ixkni0cF2YYqztjnbXZqGnX4rZTj1lP65XlJm8Ju6f cZjR8dLWEtLq2WEVqXuSLKlSVXySw4Gdj+PiP52diz8qiRecauSDQWJziJV6D1EZO+72 reucc8dqIYcGgek3kIL2nsVlvI/P2mk7whyTuwBTDd3QRagLEEYmMlpxw2LerzAbco9S fPp6zDzlH0Nvp5+0/5+d9jjIjN8co4RwZhjGGKNR1Cv+6jgwFbRiZpwf30H8yQHxQ1NW AA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 36cvyb781w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 20:25:12 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114KF7iA155864; Thu, 4 Feb 2021 20:25:12 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by aserp3020.oracle.com with ESMTP id 36dhc369rn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 20:25:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d3fCTkIox016spxStxZ1cT8ElB1mXXpdDv8TPx4sQS7FoPV9IFZ8hquV67FnNO4tzxhWdFeZB5LjQOn3Uumrx2ExDL74KaKfgcc0gR3F9SsfFvKfBaDt1aWANUve2DFqdWzYC9KzWLmMKvmuZjO/KbEJsi2SmeZC8fB+ZkpODpOzrv9Tnoe5RU5mLf83HTHgatKLcMAXOZ+gKhfZsGTJS0oGYMkQb48VcRy99Osj/7FLIN2XznKXZrtrMZYYIN1EOHNAW4rVj8UdCkiAfbm3iCb8OVHan73ZptwtYAhTpc25oiI0PnqtChnDNvLPSkM5VyB+PIhZl/HHq/leBcZ9RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z8XNkIOJB3++sM2ChemHCEjB8h4QyKCc45ubyIZXMlI=; b=Z4alHHLiZDlVR52z7G59T3gl/KsZa3v+p4wF0XCD2OKM3nvu3fS20sYsNUBlmsI+U/c/nd4BTw2FqD+/wNORDqdeDXBWmPAwK+TVGVkEpNa+MbIHI8wTc0dQzf4Xs+uyBToGSHwZFKtdS0VqIpdFtl7ffjGX93XbSqghunQKCnG9sGwnfMdbCm9nFtVC8saVOgTBmDfyBeJpoE/ex/Q+z9EHEQonWuc5dP3dPumJHMWLmOjerHxDyJjZmpG5lVUPgejVcyduTpxvQkZ2C0Ze0bJhAuBoqrlnX+zg91Jvy8FVudMCTpd1nPeJpuQWxjWxql9KGVeGfDGS81NIAFWXLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z8XNkIOJB3++sM2ChemHCEjB8h4QyKCc45ubyIZXMlI=; b=gYTsCWRXDwTOHJyhJpxBWYupOSM3RgthOV8i4QrrHHGaIBI1xOqq6SnkMg/Qli5geRVKqoOT69aSiYUSKtO0L/mjNZxPKZnVht/OcHx7eDxj/MPj81KbbKsdBceAycV9YsRsR7q49irMo0nVfn0hdOGQd3Ejex+0Shue93OQdXs= Authentication-Results: kvack.org; dkim=none (message not signed) header.d=none;kvack.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3077.namprd10.prod.outlook.com (2603:10b6:a03:8c::12) by BY5PR10MB4114.namprd10.prod.outlook.com (2603:10b6:a03:211::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.19; Thu, 4 Feb 2021 20:25:09 +0000 Received: from BYAPR10MB3077.namprd10.prod.outlook.com ([fe80::74a8:8649:e20b:d571]) by BYAPR10MB3077.namprd10.prod.outlook.com ([fe80::74a8:8649:e20b:d571%7]) with mapi id 15.20.3805.024; Thu, 4 Feb 2021 20:25:09 +0000 From: Joao Martins To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Andrew Morton , Jason Gunthorpe , Doug Ledford , John Hubbard , Matthew Wilcox , Joao Martins Subject: [PATCH v2 0/4] mm/gup: page unpining improvements Date: Thu, 4 Feb 2021 20:24:56 +0000 Message-Id: <20210204202500.26474-1-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 X-Originating-IP: [94.61.1.144] X-ClientProxiedBy: LO2P123CA0104.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:139::19) To BYAPR10MB3077.namprd10.prod.outlook.com (2603:10b6:a03:8c::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from paddy.uk.oracle.com (94.61.1.144) by LO2P123CA0104.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:139::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3825.21 via Frontend Transport; Thu, 4 Feb 2021 20:25:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6cf37526-1ee7-42b6-9184-08d8c94af7e7 X-MS-TrafficTypeDiagnostic: BY5PR10MB4114: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:635; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ulOR6FnaMqKvzZSoJy2j5tx6IrkMbm9huFMIXLDAtvCTEFGwjRON8aIeZng7CuCBpXMO5v6U+bGyjAOoVLZ925OdGNcMEBXSSQzRUaV0ohaNwwA4tntMN7+a8+dEVT2WGSzqz8tklArkiSl8/CpXtyUw17eLUCprZxlllEg/u6E3SRxWFQ3vR94EXdvu4SKQSsZwLatguHLBviTrV4Tih3RyaGhI1z9Hy1JWtgURLx9Iii4nCGNMUTJKG0pTCmOTAl/8qMpquqy2EvXC/NTCESbsaCqKObgYOVn55gBM2VAYpMValLb8DFBve7GrRw9gMRB5vUIbA5wVHvnmhCsc6a3rNLDe/e7ENZzUjqO1Cf2HWqNuobHIeO2I44j37zcqhPxK2REfbJFMNOWHAKBWwtyvLuDP4XZuaXsD61Xt/GASH8Lf33b/9n7QXcUocfhIMcUDrd7HjCmKjm5laV0hNvrAEZH/aM9EE6e5SqSyIrJwTulMuDkiY62Ds/8tTqZd7aiEVQJTCmryjo4ftsQZlpf/nFkTk4gUSRdnFMEI1FKpLjlARS9f8GJwVz2tAZmlh4BtOAycdGHpeG1nP9jTfqVpEIzkkDZq/TQns9ZdrY4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3077.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(376002)(39860400002)(136003)(366004)(396003)(83380400001)(6916009)(66476007)(2906002)(316002)(478600001)(8936002)(66946007)(66556008)(107886003)(36756003)(1076003)(966005)(86362001)(2616005)(5660300002)(7696005)(52116002)(186003)(103116003)(6666004)(26005)(16526019)(4326008)(8676002)(54906003)(6486002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: kSu6mODBTmy1/hMRKw3VxlLHT6Dqyp1ssaeHHMLYVcE79EeDGSUROzy17S3Vs6AXW4/GFaKEAgYegtCJss+C0+I/rzqRkeOiqr/iRyo5tGekAn0sxmpXtKkAnw4sCRTe1fPXnJs1UFrKGx1RyD3OSkwfWK1MBxXwIlcPFkPbj/WJxzg4DM6o0s8avXdEPKi76C0EXjulwSN5IXn8DC2jth9or/N6lqhmyCmAqREf2MyPf2teETpnP6dSK3UB94OOw+1po0lUK8MzFhQjhFb75TuApEjHmEvDXkDK8l1b35BecgvThqq4z0keePVLg5wsYOGZJv8zDBmm5NlvM/MJqd+CH8b1VqhWZk9qTJY5AdPcOxLKxC+TqNeOfwNsoNLTukRhzwUplrsPv2VXXQ4WNlFVwirx0B0uEMXwCV+A7xSRQEgNYVAs4hN0Seo7Wmo2LcTaxh5GgDuRIe/FUnjFd5GogOjqxtznI7AXa1Qg+LiFwgGIV9K7s09Gu2Tvp5F/2t6t53yadEOxFPnCqlD8VNHz5ZfoN6kTOrMNBCZJmI3mymhIgvGupFSKTIBYfqXBcEoOLSnC8pBtWFzeGOl0FS830cwlv+BMo79SlAabaypGbJzvtrp4ZUzvYLxPalwcvdQ7l2dk7Lza+AQ2jws5uK7PKqiKftz0OO3pp122V7s40RHmwzUAzNszWR0D7ahNg6l3RH4eFPaiLYI1LWsppHfPtZ5bt9ilMDZ9xzG1MQtjmXjsg7qZWMxoNnj46ltTXBjT6ya/P46EkWwKBZHjSnvyduc4fPGg7TaAxtuq8JIGArBxLQLIeWi7WHFtgbO+imSpmgDVVWxlBvPVrgFTG6Fd/FkYA3nvUz/7Sd/rdQQG/7PYm7xE7KsvHDENpWyaO2J10vSk3dPdUFcel//N0MXc8kwmULCPIFjcgqSYqfurr6nnONUKcmAqJQPX2dE48DS+uzeHFyGsw8wLz3ZOU001iDBxu2FHBOGypKL9TqYNbvG/6iaP11lZze/5CCUDYRUGTsmnfJUm5FhGp1fVOnb5zn9pm6wdyiCTIYa5eolJeIrzqCpQ0NsBlimkyWt0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cf37526-1ee7-42b6-9184-08d8c94af7e7 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3077.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 20:25:09.8445 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SAzbkEH/mBLpO9ohH7uJtBTv4j6Nq12Iv8yogVBPH/XIZQsrYB4a9YDi0IgW43TNtM94/b6OKPANMXXIJWievjXVaX/uW2xDVlYqkzepCL0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4114 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9885 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040124 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9885 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040124 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: Hey, This series improves page unpinning, with an eye on improving MR deregistration for big swaths of memory (which is bound by the page unpining), particularly: 1) Decrement the head page by @ntails and thus reducing a lot the number of atomic operations per compound page. This is done by comparing individual tail pages heads, and counting number of consecutive tails on which they match heads and based on that update head page refcount. Should have a visible improvement in all page (un)pinners which use compound pages. 2) Introducing a new API for unpinning page ranges (to avoid the trick in the previous item and be based on math), and use that in RDMA ib_mem_release (used for mr deregistration). Performance improvements: unpin_user_pages() for hugetlbfs and THP improves ~3x (through gup_test) and RDMA MR dereg improves ~4.5x with the new API. See patches 2 and 4 for those. These patches used to be in this RFC: https://lore.kernel.org/linux-mm/20201208172901.17384-1-joao.m.martins@oracle.com/, "[PATCH RFC 0/9] mm, sparse-vmemmap: Introduce compound pagemaps" But were moved separately at the suggestion of Jason, given it's applicable to page unpinning in general. Thanks for all the comments in the RFC above. These patches apply on top of linux-next tag next-20210202. Suggestions, comments, welcomed as usual. Joao Changelog since, v1 -> v2: * Prefix macro arguments with __ to avoid collisions with other defines (John) * Remove count_tails() and have the logic for the two iterators split into range_next() and compound_next() (John) * Remove the @range boolean from the iterator helpers (John) * Add docs on unpin_user_page_range_dirty_lock() on patch 3 (John) * Use unsigned for @i on patch 4 (John) * Fix subject line of patch 4 (John) * Add John's Reviewed-by on the second patch * Fix incorrect use of @nmap and use @sg_nents instead (Jason) RFC -> v1: * Introduce a head/ntails iterator and change unpin_*_pages() to use that, inspired by folio iterators (Jason) * Introduce an alternative unpin_user_page_range_dirty_lock() to unpin based on a consecutive page range without having to walk page arrays (Jason) * Use unsigned for number of tails (Jason) Joao Martins (4): mm/gup: add compound page list iterator mm/gup: decrement head page once for group of subpages mm/gup: add a range variant of unpin_user_pages_dirty_lock() RDMA/umem: batch page unpin in __ib_umem_release() drivers/infiniband/core/umem.c | 12 ++-- include/linux/mm.h | 2 + mm/gup.c | 122 ++++++++++++++++++++++++++++----- 3 files changed, 112 insertions(+), 24 deletions(-)