From patchwork Mon Jun 6 20:37:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Arora X-Patchwork-Id: 12870891 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADF92CCA473 for ; Mon, 6 Jun 2022 20:39:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44E158D0005; Mon, 6 Jun 2022 16:39:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FDED8D0001; Mon, 6 Jun 2022 16:39:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2501C8D0005; Mon, 6 Jun 2022 16:39:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 177DC8D0001 for ; Mon, 6 Jun 2022 16:39:34 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id ECFA03338D for ; Mon, 6 Jun 2022 20:39:33 +0000 (UTC) X-FDA: 79548976626.07.30E017B Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf24.hostedemail.com (Postfix) with ESMTP id 5D1D3180038 for ; Mon, 6 Jun 2022 20:39:16 +0000 (UTC) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 256HJ0oK019941; Mon, 6 Jun 2022 20:39:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=PkuCAOvPHyodxuo0lxQ/4fnpf2Sh3u+TVEsU5WG4ZLs=; b=LhFr3xc+QIi15yT9Oae9jpSpHxcWNa7awPkHbOFwS/eXR10XrE3j65CBCqCofBrBHHbt piCd1h4vtKRJp9exHz/FYOV/Uml6HYiMNbOxW5G5FIHNeNNr6UIfRI2P+k8OFaXCjjDO VFqumIizmDokNx+2C+UZL3qmWuB/RFrD6sxLmkz8NUws7RiiK1tlMUaVgPJA2Amrngxo pakBkPK6/sYCOksrZPqKdZ9mP+ts1FK5yNqZsykWDNwA3dtS7PBEHrHAmC1j93hooJYR n7yf+a13unHl8fySdckNM5s3ZPI0j2nfsex/ExhCIoG41xJhl/RQaPnPn3h4rDf26eYh 5A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ggvxmtg0m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Jun 2022 20:39:17 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 256KFsx6016233; Mon, 6 Jun 2022 20:39:16 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2105.outbound.protection.outlook.com [104.47.55.105]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gfwu80ags-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Jun 2022 20:39:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DnDBrCtK6LKuHOl42KCS7T6PGO7zifUYgzXNNXK5LWziScwsq2T5hqpEmfyhgHATvGN4Aml1uL9wC5ECYgem5uIzQoqW0oRQAw9VfAhmyYDehmpmq88mDAkHKAs/u39uKCe4m4AT56TDSGDkgqgG3MlNM5zhcdl56IR9uXkkWNqyXKUksDE2RPkasjCyi3XNT3/iXk+pll/ja2lMNqqsK14SqiRkoYrkzCccrSE+UXKBZAY/hcW0KD5nsGM115sU5PQq46sJft5vpABHsdbV8Rn8q+9uRJnaOdjYcD5DaJ/qWiGUw+Nk7miKCRdeVBAzlNiEqdECK4AzJa6acpFU7A== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PkuCAOvPHyodxuo0lxQ/4fnpf2Sh3u+TVEsU5WG4ZLs=; b=eF90TXRyDnmFWdtu4ilRqMuwroGER0z3OeQVbtuoqjPjDiC8vEA6R6OpkhmacYorfzl2u14p7MD0MizXEp2f48e1LTuDlXVqMGhTzS39JtGKmRV1MQgfc81EJLCwCiIZvnm2tuPGe5H3qExnXa7jDyPAw5JAvUO4vtX+cZoe8cyiBGQw9AO+Bxp+oYtQFh+QK21ihiJLzdh4xY3a0N/5FRvakO5N8WON/H4C414wqwINYryYtjkaSce5jA7Jp9V/50oZOQ+d9nWlYLy7fmbchBy82uA7o1KrobHmSugws9oJL/iGxnMns2ZV17Ho7EUmxCaaasrrhcsaGoU70Gcabg== 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=PkuCAOvPHyodxuo0lxQ/4fnpf2Sh3u+TVEsU5WG4ZLs=; b=T6qXXSaCbuPiXtpDyT/YpbXBkKsfpZZ3L0ZbMJVlW6glRAHk7GQVOp8IkDoVY0TsTsO6N1JeK1/vxv8/ULMw3C9fVf7+OMpc5vgiXK/sOU4P9RCnO/yO9mZgcixGxAwEYtna9Vgo7Z8I7HjEr1n3rpiV0h+D0/wZVJTU0l5RQSc= Received: from DM8PR10MB5416.namprd10.prod.outlook.com (2603:10b6:8:3f::19) by SN6PR10MB2734.namprd10.prod.outlook.com (2603:10b6:805:41::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Mon, 6 Jun 2022 20:39:14 +0000 Received: from DM8PR10MB5416.namprd10.prod.outlook.com ([fe80::49dc:6a95:a2d5:fc08]) by DM8PR10MB5416.namprd10.prod.outlook.com ([fe80::49dc:6a95:a2d5:fc08%5]) with mapi id 15.20.5314.018; Mon, 6 Jun 2022 20:39:14 +0000 From: Ankur Arora To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, mingo@kernel.org, luto@kernel.org, tglx@linutronix.de, bp@alien8.de, peterz@infradead.org, ak@linux.intel.com, arnd@arndb.de, jgg@nvidia.com, jon.grimm@amd.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, joao.m.martins@oracle.com, ankur.a.arora@oracle.com, alex.williamson@redhat.com Subject: [PATCH v3 20/21] vfio_iommu_type1: specify FOLL_HINT_BULK to pin_user_pages() Date: Mon, 6 Jun 2022 20:37:24 +0000 Message-Id: <20220606203725.1313715-16-ankur.a.arora@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220606202109.1306034-1-ankur.a.arora@oracle.com> References: <20220606202109.1306034-1-ankur.a.arora@oracle.com> X-ClientProxiedBy: SA9PR13CA0176.namprd13.prod.outlook.com (2603:10b6:806:28::31) To DM8PR10MB5416.namprd10.prod.outlook.com (2603:10b6:8:3f::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5685fea1-4242-4edc-19c8-08da47fc9e54 X-MS-TrafficTypeDiagnostic: SN6PR10MB2734:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5yhIKur8HwoTUn0EmJLNAfSLUBvLlaN5yZkCuQrFQO5s+xKSTGoZqUAuz0wIfdDJ2QHXpzaVW0z92r2SHbauzLIxHVtj7WrDOFEgVgMFZt1UG04vPiq+L9/Hf9wdlInNrt3ImaSxrqBRx7hEWB0qk40jkNi3BlNtTc6vVt82Uwm9f9247JENLOFV+JYcdWFA7FSHGhdixfUhVdjjrR2QVSgfN9NuJsoomHISy4E6FJ5t3xuKX0D0eG00lGcBx67lLCnm8ZR4IB8eCgxhcWXNDgXA1gHsRvIaJ4uMYwVv3V3dNMhsp613a3cxf9IdJi5hkSfmk+A4oXsg0OCuuBVAQlow1T3P7eeGn6qWTyv5aFApvzZrieKe/khjcw6BmynDhzOzqmKliJu7x4wfz9RbRMUSC9EQsrriDOZKeEA/YptnWC/BAZ0dutkBqJcgXejtJhMWUP19NxpNXvYZtgZUZC8kXk3+49bJDdFV8igjcSduZlujUZAuH6aNjwrSZbgmZBa+M0skzR1H5KOxh9MwVde475LikmEPMoJ4eZevGRsQO1tavvmJEkNBSpm1AJr+c070h7Tfm9CC4P0Tvablu2xHy4sg7ty/Vy81Pog1WIy5UDsEXAhyuSqCVXz9Xb5LS0+6+NsQt1vtAogC1uaQUOucFvFV2u0fL8wRtiSexndKXJZgkIYUGbfPK5xjqVP9tzh8DaFOre/Ok+QfParocg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM8PR10MB5416.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(8936002)(83380400001)(52116002)(4326008)(2906002)(6506007)(1076003)(8676002)(186003)(508600001)(4744005)(38100700002)(38350700002)(86362001)(6486002)(2616005)(103116003)(6666004)(66556008)(36756003)(7416002)(6512007)(26005)(316002)(5660300002)(66946007)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8num74lPgp/AFnZ626oETUsU2MYjBLPZ4LX7fGBD6XUw0AFgPbXJPDJcYrogO28tmTtKg2CRqR9m9z+g3pMqEkAHkTM4lMeLhQ7d/GNFebqPueJhLk21HCsreQCHP9h3IQW5A4Hj/QxL9lf1F+cvzWJn44c8DYl7roBI9AWgykQdS6pXTG8jXXM5zu7YUgmtQSE9jOFP6Z2OejW8jijutSE3cVbePZdYY2CfX6cthjnbWnfK9QAd8mi0poOcDyCZnGtfR2lQZ/lCAmTJ5j3gwQQ0so1OcQbLDTT5kWqiM7dW+ATxtVDSa2V1GHgcbHqc5SAAFpwhnTHOWILA2RPQv5IUfOP+pZ0Ow0L64Q7y4d+QM7/TrH4S+PcZyLrtsVxT7KChKNDzQhNe6A02eLzvzhonx3OFE5ju82mHP1FOQYF4tgMQYfqb3OWJjjfT/nepYMaqDFZaU3wHqFhRxfR0GzgtnaurCKtjkqeef1LuzUdk9lLgMYqf7/tzY5R1EKTO3uMRiIaEx2o0vTPEVqTRKm4QJFjo6WCVYajeF83P+7+S2HB255dxVLDSHMQWH/ohDtIBUM56L3Qjxg2ZHswaXexQVmR/4HrOZPov/DaiYfZ1boxfg5jK2j5kphxqyV4F6Zl5safUEpZ7y/5EO3dTFqB2QfrTAB+m64Qi8oJarNV51z197JTPh4z3N+C5tC4/ncRqRTivq7ssxcRxTIzGICe5Tb819PBHvrWpCFGeb3cxvrxv1TC/TuLoUwlWcB6rOspkO7xv0byDYnHXo+/iIrICxkHJ2SdwvDEOi2ALOqNHmZ/9hNL/x4gGLIN4BTD9ydMHUrbsD8IzlLqSpg7FpdtcjUmRcH2A1qCOM3HwGv25l2TiT+vEX3dgxlsuqlg6emv1SIc73wXR044ru8vs+EGKnG4IcrvdpRFGwdwCYEr17nT+ESqffz1k82BJ7W8QOBIdcZdVJYXNhpfQ0WSux6tN0apZfXVigw98KHXC8QCQ2NG5X1RYgLnYk87OYONroo3mdCwGI7QTKz9WiTNUFyTPdoSTE4mw4io7HQxPl7BybsQCl6PMLaoEIKeyt9MX74DB7C343VSSgN/nZWRKDpL1ogdSj+QJTNbPEowc0eH808gacpWaLgZjorHXK1aUJQQVwKONWZylcAlho8+f+0gd4WrLbYPxZMS0VHHZMwhUlJTPAFsPrFX7jV7oYaMEfjDyCp6YRjoe68+eEi3xyw270DXVRaBTT1i/C5uevY9HI00XkwK4Ptt1LQWQKjW7kfye1EdIs4WZ8IXeyqwvjzykqKwQrQHazKJyQPqac/CuFs9h47g+bdhmIR+Wb/aBjxHiS4fV+8lC0O/21A99ZQ9IDttL25uw57jrQswCkNdPyBaIvVDpZ0keSYnFnxgBJtEz14wC9f4m+xcknALsGVx1TD9cVx77/ND8BfeDEtpxV2WQQqDYkJwU86f3PDrq2u3mq0fB/z0P4kbMgJI/GfS3bXUR6efbDXqzxb6HqCffrUpNdXiJ+aTztb/QyFqhkK/cac/C6+MJZh0po6I5YCmRGgCaGyi0qfydZUYFuPBZfWS3/PvkadJC1gB2XiY3TZHrtIe70CLCig/HG5C3cAWfXk2+K2+307RYDyY3xh7KPthkazmpXIZ2WsETSSIRTc6fD17FbaKjtLcz2aljrLCF/7OSYiS6gWhDycMy9+6kuPYfo53hWOBzc/pStNGSIrWWQlZiNIA04F6pGiHJoaE2IMi7TgvE2MCRrudOljU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5685fea1-4242-4edc-19c8-08da47fc9e54 X-MS-Exchange-CrossTenant-AuthSource: DM8PR10MB5416.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2022 20:39:14.1707 (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: gJIi+75btb6esrWQJjL+WL4rRszu3Ygc+KqmeGwcM+K1W+z5jV+mP6Y6SetwgKGEu7jwaebwv+2HYTrm799+LHrIO2/BDbiP2uiiewlejg8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2734 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.874 definitions=2022-06-06_06:2022-06-02,2022-06-06 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206060081 X-Proofpoint-GUID: BJIfJo3FwDi-f3Nj_S944Ik_UlToqORL X-Proofpoint-ORIG-GUID: BJIfJo3FwDi-f3Nj_S944Ik_UlToqORL X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 5D1D3180038 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=LhFr3xc+; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=T6qXXSaC; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf24.hostedemail.com: domain of ankur.a.arora@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=ankur.a.arora@oracle.com X-Stat-Signature: s6xczpbmdusknjfxd39fq8h7jny9gfzj X-Rspam-User: X-HE-Tag: 1654547956-776053 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: Specify FOLL_HINT_BULK to pin_user_pages_remote() so it is aware that this pin is part of a larger region being pinned, and can optimize based on that expectation. Cc: alex.williamson@redhat.com Signed-off-by: Ankur Arora --- drivers/vfio/vfio_iommu_type1.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 9394aa9444c1..138b23769793 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -553,6 +553,9 @@ static int vaddr_get_pfns(struct mm_struct *mm, unsigned long vaddr, if (prot & IOMMU_WRITE) flags |= FOLL_WRITE; + /* Tell gup that this pin iteration is part of a larger set of pins. */ + flags |= FOLL_HINT_BULK; + mmap_read_lock(mm); ret = pin_user_pages_remote(mm, vaddr, npages, flags | FOLL_LONGTERM, pages, NULL, NULL);