Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp502921rwl; Thu, 30 Mar 2023 20:37:55 -0700 (PDT) X-Google-Smtp-Source: AKy350ag0AQo4Ht2PbKrq7XwLxymcq36sPzuWT9SU5pD/a1zVkQABBfY4g7XRhbwb0YUUTpj4Olx X-Received: by 2002:a17:906:7390:b0:947:8734:a058 with SMTP id f16-20020a170906739000b009478734a058mr2289310ejl.4.1680233874977; Thu, 30 Mar 2023 20:37:54 -0700 (PDT) Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jz11-20020a17090775eb00b0093f2142c91csi1056679ejc.772.2023.03.30.20.37.29; Thu, 30 Mar 2023 20:37:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gTYEV7tq; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229819AbjCaDg7 (ORCPT + 99 others); Thu, 30 Mar 2023 23:36:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbjCaDg5 (ORCPT ); Thu, 30 Mar 2023 23:36:57 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7AADCA27 for ; Thu, 30 Mar 2023 20:36:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680233816; x=1711769816; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=ITeIKSCZb2ML9jNy4q96p8GX9m674UHPjhUZb6Aif/g=; b=gTYEV7tquQm1VnMVYio/hZzdA11hTl+yAgacp0kqSBTgR6/FnhB+pZ4W P5GnC1bCEBcnDxuuL7HPG9jfYPLFh6l7LsgVYeVqOIwWb0hiokkC/y8fM U7iAeFiBGAMGs/E7jpkE7RPOjzOJwCN4D7Ie5WJrwtCVY3RtdKrX+4aNP qeSib4yu7EGaBEWb/OAyEaLevOvGZI5WMcPnM3T5mXxQMR6/zshJFVgfp RSgp4BAct2+rZ2vGbz5qfsTy/59F7WUkr08w5PASiItjsfo6XjwIBN3Qk aMPKihaDOw5ejM8SgJMMOwcIx7ANZNuNhfKt69Drgwm5U38sRdarviGL8 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10665"; a="369132303" X-IronPort-AV: E=Sophos;i="5.98,306,1673942400"; d="scan'208";a="369132303" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 20:36:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10665"; a="795945664" X-IronPort-AV: E=Sophos;i="5.98,306,1673942400"; d="scan'208";a="795945664" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga002.fm.intel.com with ESMTP; 30 Mar 2023 20:36:56 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 30 Mar 2023 20:36:55 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21 via Frontend Transport; Thu, 30 Mar 2023 20:36:55 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.172) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.21; Thu, 30 Mar 2023 20:36:54 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AKjZneCUOCxJa4V/aOpc8BpV2FEvRrZbcL3x8h5Tvgejcj4oD0ZxMUqSh1HlVLug/oofYGpAvgoIZfKScYZjcvvTpGZuPsLcVwNJ8DHZBZ9H1x/FFvM7Zm8aNSIKsuw7fADwIaHA45+vC2jsZ7tbDVTUtgM0D3UPH10fm9Ddrg4TjrTkELDhdzh8z7gDRQcqSBJzUMyF3DoGVLoTrkO6cq3+7EUD+84wvyP73wDJOFkfhR/Svkn68rgX5edhaFcWkNCmSXpiYSEZ/E2cAEVEPxF3t8PPMpQAEvZ2HMXbNaPkkxuEq6FJxTNs1Eg3A5QlmukI2Ib0aqeBbvMOvYcv4g== 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=l9rVXGSjG479BtmK2inO00NUHDmZ08YV+7vJmpcFYbE=; b=FGdjZXyXUEijsd6uBtC7snvQ9P8wz3I5SbMMfdu/IrREec2ro/1eMmysYebHtdmIbkv2aKZ0O+UsIa/am7rOTe9pTJ6PIcq+V4AQyfAA9MIPRY1h6XVBDcEi43iDRP6BRowrc5WP1L6X21ZtoQp1evMIPgueB9pZtoIRivQ1V6Mu1HToU+zLEuxD0ZJ4Q/jyvJACAo1vPG9BFh0lvEXYlhZjnXRM1WDk+IcLMxqpvnpWoQhg0pPQb3lkvTiMvxDEhHD0PYZwkdI2E6bcEZckzH2976eZaY5qB0urfIFXubh5zxie0356jb5aE+TPXE9MNKOSTQI6lgkMNx7+CfIkZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SA1PR11MB6733.namprd11.prod.outlook.com (2603:10b6:806:25c::17) by BL3PR11MB6411.namprd11.prod.outlook.com (2603:10b6:208:3ba::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.22; Fri, 31 Mar 2023 03:36:49 +0000 Received: from SA1PR11MB6733.namprd11.prod.outlook.com ([fe80::c5b2:6996:5aee:91db]) by SA1PR11MB6733.namprd11.prod.outlook.com ([fe80::c5b2:6996:5aee:91db%5]) with mapi id 15.20.6222.033; Fri, 31 Mar 2023 03:36:49 +0000 Date: Thu, 30 Mar 2023 20:36:44 -0700 From: Ira Weiny To: Zhao Liu , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Matthew Auld , Thomas =?iso-8859-1?Q?Hellstr=F6m?= , Nirmoy Das , Maarten Lankhorst , Chris Wilson , Christian =?iso-8859-1?Q?K=F6nig?= , , , CC: Ira Weiny , "Fabio M . De Francesco" , Zhenyu Wang , Zhao Liu , Dave Hansen Subject: Re: [PATCH v2 8/9] drm/i915: Use kmap_local_page() in i915_cmd_parser.c Message-ID: <6426554c3db9a_375f7e294af@iweiny-mobl.notmuch> References: <20230329073220.3982460-1-zhao1.liu@linux.intel.com> <20230329073220.3982460-9-zhao1.liu@linux.intel.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20230329073220.3982460-9-zhao1.liu@linux.intel.com> X-ClientProxiedBy: BY3PR05CA0029.namprd05.prod.outlook.com (2603:10b6:a03:254::34) To SA1PR11MB6733.namprd11.prod.outlook.com (2603:10b6:806:25c::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR11MB6733:EE_|BL3PR11MB6411:EE_ X-MS-Office365-Filtering-Correlation-Id: b01cc12b-6b1c-44c3-1924-08db319928a5 X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aBmPN+WeAn4Zv8MRV7jcdeT62dWFoNSYUjiCqou/sp7ua2x7MOPxn019h/oaXLQoPkyWklu7ENpnlUCXp+pXKNXqCTkFvxtvUn6SR655G8Gkr9gCwG9061pjE+lgyPc14gE1GvlbqvhmEmkH6U9Q9pvU8XyEPj3LhSG9cW6GFTXelWVCSJtaOkEPSyYMY8kB8tXHzVXvpIyQsNTAuvAhDMFm+STJvShWy9UjtauYnsP4WcPrMz/Sbntm+qhPblb438LLe6ZbHxKI/b56aJDuTHK4ap8MvYA6gAyzgqWSJj1BZCiKIS7JXlNJqpFP6JvOht7Py45J3FkC6inoicKQm7swo9HluKqY9MjYjWKiOjaYl9XmqicC76rfy1jV+LoTMnMAJLGm/QoFCSD0IAFLX8wV2tebRCsUAFOdCql7NtpBop7PBWdeditnKc4cBc1nsmDDhNPbsT8ROxle9BiEWO5I3HuCRv3JDzhA4Z+7UjXi6gaPd4bLvAwEAMPQ89J6Ak9K9at8qTuQ0PaLr+yEQBQkxFmhAjpF4jh7WnxGGw5d0vSnwkiLAsQF+Jt87gwx4rSxtkR4N1p9oA8XWbZ0MEHSdroOFMZoGJ6hcPiL5rs= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR11MB6733.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(366004)(376002)(39860400002)(396003)(451199021)(26005)(66946007)(9686003)(921005)(7416002)(8936002)(6486002)(83380400001)(6506007)(41300700001)(66476007)(316002)(2906002)(38100700002)(54906003)(5660300002)(6512007)(478600001)(86362001)(186003)(44832011)(6666004)(66556008)(966005)(82960400001)(8676002)(110136005)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?zNVHNJctuHkkDWe0lKDFm+AZSt8f/aSe0WfX0bYsKsRiAbdE/PkKZTrBH55B?= =?us-ascii?Q?boBsCG9WVAry6apmf6mMhUYv5SGg02673HMsF6tDs8UBz60b09EFFgjxv9d6?= =?us-ascii?Q?i1WFao+YwqqFoWZgpayKV0NR0tnVRUVyn0Olt1KZnoL6Z16gN+FXjoEpHV3E?= =?us-ascii?Q?0EWy3wzpSMDdzOOraZhartchuKLG6IEbPIcyONLGfp47Hi1v3tSjsJRUXBek?= =?us-ascii?Q?4+8mNEhe3IWx3wo6HDompUuPCbSSP6kFB+URng3sS3kWdbMxLeuj5n1coNP8?= =?us-ascii?Q?r1LsgDw+VE8gsOY/WT8IJz8OeIaDW6ZdWgMAkdSaHyEoGAYumRFZvKGidB/1?= =?us-ascii?Q?kZloObge0/PczNrsNrcZk01b/0sA9/U1foDy8Y5n5LQfmdQERNhzF74ZY/VW?= =?us-ascii?Q?TtJ+ZPzMUr3saIy/LFqsGtjLJWUH77mdIUwqxvGj/1TWLXXqQDDb8tztsMiI?= =?us-ascii?Q?Udxltf7tQ8ueXEBGaVtftJCP9bRzmnVde1XbGlHMKLQbLkuT5YMP64T4uM26?= =?us-ascii?Q?L0Oxu/gTWozADlG+pJ61hTO0cafhdM2jbJNBrzBsF0XRboI65GUCUL6k/842?= =?us-ascii?Q?zty4hcnzeQksrFt2BgHtWmLXXAtEAgi0uVhITkzcK9rFrgonewqjWQilH3Th?= =?us-ascii?Q?SEEJGPZA1x21cQEDFYssDN83T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?5iTKjzn9X9vQMx0nu2QK3/8zabAIBWdDhElUhZJQ?= X-MS-Exchange-CrossTenant-Network-Message-Id: b01cc12b-6b1c-44c3-1924-08db319928a5 X-MS-Exchange-CrossTenant-AuthSource: SA1PR11MB6733.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2023 03:36:48.7428 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Q3zBTSqK0GlvSmDc3ftQ11OuHn5dizsrMvIEgF0N8NGH3D2Uo3sKH2O4EZvu3uCgehIR0U8j1PfjEE9i/+Ll9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR11MB6411 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Zhao Liu wrote: > From: Zhao Liu > > The use of kmap_atomic() is being deprecated in favor of > kmap_local_page()[1], and this patch converts the call from > kmap_atomic() to kmap_local_page(). > > The main difference between atomic and local mappings is that local > mappings doesn't disable page faults or preemption (the preemption is > disabled for !PREEMPT_RT case, otherwise it only disables migration). > > With kmap_local_page(), we can avoid the often unwanted side effect of > unnecessary page faults and preemption disables. > > There're 2 reasons why function copy_batch() doesn't need to disable > pagefaults and preemption for mapping: > > 1. The flush operation is safe. In i915_cmd_parser.c, copy_batch() calls > drm_clflush_virt_range() to use CLFLUSHOPT or WBINVD to flush. > Since CLFLUSHOPT is global on x86 and WBINVD is called on each cpu > in drm_clflush_virt_range(), the flush operation is global. > > 2. Any context switch caused by preemption or page faults (page fault > may cause sleep) doesn't affect the validity of local mapping. > > Therefore, copy_batch() is a function where the use of > kmap_local_page() in place of kmap_atomic() is correctly suited. > > Convert the calls of kmap_atomic() / kunmap_atomic() to > kmap_local_page() / kunmap_local(). > > [1]: https://lore.kernel.org/all/20220813220034.806698-1-ira.weiny@intel.com > > v2: > * Dropped hot plug related description since it has nothing to do with > kmap_local_page(). > * No code change since v1, and added description of the motivation of > using kmap_local_page(). > > Suggested-by: Dave Hansen > Suggested-by: Ira Weiny Reviewed-by: Ira Weiny