Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13186050rwd; Fri, 23 Jun 2023 17:42:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4QtgNOmOLlIp5tQpvKf77NofPK+UZ0TtQ07kwbYDpMn+WJvTgsvRPdYm/rxiZpl6JNPdjR X-Received: by 2002:a17:902:9006:b0:1b0:637e:e25a with SMTP id a6-20020a170902900600b001b0637ee25amr544061plp.67.1687567341722; Fri, 23 Jun 2023 17:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687567341; cv=none; d=google.com; s=arc-20160816; b=m/PIuxA+sxfMshdd64qyPrfk/y40b1tljZ2kSsBMUwqmQ0AUnu4vT85ue81Dgtw0wp cNn4VtxeCqh5ymklzroU2LhbNRV10EQgiLh2KCSBgzcyp+kIysPrypjDkUtKKrpJnAoi +ZTWQDtQS552nsKI3RYx1TSnRMXNLBuq4gDl2Hse8itXoKCRBNjlEBT9eQidlCKRunof L6jNJrMaNzdEt/nQig8bBlWD2D0fj7a//VzPo++l4tyQPHt/Puz6T+883vV+UVzLTErh r/qM2wqC/2jZbqHHmz5cR1FbcXAKV1vl9mUCVvu9yMbUHA1/MRyUcMX+hF/OnBKaXeaM ZX4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=juyXTwoXsD5mc3/9HxZ2a7x6dEyqzG8iNP0iF/NU/Ww=; fh=qokLNs3TG/Pm2avmqDOiop4C03tMOr2posWWl1pflvU=; b=L3k+eFiG9LKgpcfgspjjN5gWvG27ieMr+fneoENWRRwoVyEldWIFlb4r5EAKZIVvGi laaVAkVLQrONqFEFjzzcUk1rTlW9RGU2YkzWtl7ELRUiEiD0MKVL5jRWJLsrLIF7tChU h9UgDM7HrPCIgvC3DmNEMYO0TzkdZZV7o7yix7Kaopp9lBmNxufmdOgiO9a5xDv0yqd9 bKKtm1GfSgnK8RIZUXXM79JPsqPhMg85LH8MZoMbJmbFcP2MkUyEmy4fuzrACXeqQFSt fQgde1AE8UqcA4xevqrMix7AU8CG0b9vcomvaO4QIU+dlFX7u8awGd3f71gOp90ivizB pfEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="MmN/SfQT"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a170902c94600b001a95d336558si315790pla.594.2023.06.23.17.42.09; Fri, 23 Jun 2023 17:42:21 -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=@gmail.com header.s=20221208 header.b="MmN/SfQT"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229864AbjFXALE (ORCPT + 99 others); Fri, 23 Jun 2023 20:11:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbjFXALC (ORCPT ); Fri, 23 Jun 2023 20:11:02 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04AC82726 for ; Fri, 23 Jun 2023 17:11:01 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3113da5260dso1219373f8f.2 for ; Fri, 23 Jun 2023 17:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687565459; x=1690157459; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=juyXTwoXsD5mc3/9HxZ2a7x6dEyqzG8iNP0iF/NU/Ww=; b=MmN/SfQTVSwstgn9DyjaDtUGPN9gGSs1fKgJhKyBKThnqBlzJRMvrsZXPQhG7IZe6l Iol5bu6RICV3a7Kqq6nWPWp79EDI0fSs17/LPya2OphEWx0/r9XarsggkZW+1Uk+abec 0EgxJvWiL3xLH5ZW89jXCzFzF9gaY0Q8rTnblSu5fBESLpe3k1XgFH9ijWHl3DAv69Rf uE9zuWu4Isj/VgmfQzMy0sh0KPHMbR2QzZMzAyM6n32bIAf8xcUPAr/nxTixnHPoCiJa TVoabV46gMriN1+rwOxHV3Kn7Mviu0ySlzK0u+mp4cHVFeJwhpsMdoOtPYSBEYe3zoix pwQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687565459; x=1690157459; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=juyXTwoXsD5mc3/9HxZ2a7x6dEyqzG8iNP0iF/NU/Ww=; b=YHngaD4DLHxAQka09qLjZuMUxXLxxtXfHwVCKODauGld9Gwfrb1k5bUNaoflrOqVVj 5qAZpAwX47r1WMxXfQ/EArXM0XFpkGxS8bO9EkcYrXyNa4GCUXbkaH1/RD2fktFEMnau tz9iNAq+m45z/H/5Q/HFvPNhk4njK01Gkw+9OLjCu0U96uCozUx2i9MQTyzFm+clJ8jg b6E+iJtowiw4LJ9SnlKX0sMr0xbrS9KFtp6rfi6DS+fJ7hG1XqYbC+wkOKm2Ff2S92Xk 4qoJMMBIvU6qJZvIodG7Tcxospih72yvA8Rg9E6YaBotv6sW0poxnk1+0GoJmk43NVey V87Q== X-Gm-Message-State: AC+VfDyqzPzreRU7fuiinrt7A533FDPLBJnzY/WYcZMXsFOZXyyqjpI1 CkGg67cWni2My5nK3Q4KU0YJcxjUG2E= X-Received: by 2002:adf:f847:0:b0:309:3af4:8c8c with SMTP id d7-20020adff847000000b003093af48c8cmr14124282wrq.54.1687565459046; Fri, 23 Jun 2023 17:10:59 -0700 (PDT) Received: from suse.localnet (host-79-23-105-164.retail.telecomitalia.it. [79.23.105.164]) by smtp.gmail.com with ESMTPSA id j9-20020a5d4649000000b0030aefa3a957sm653882wrs.28.2023.06.23.17.10.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 17:10:58 -0700 (PDT) From: "Fabio M. De Francesco" To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sumitra Sharma , Thomas =?ISO-8859-1?Q?Hellstr=F6m_=28Intel=29?= Cc: Ira Weiny , Deepak R Varma , Sumitra Sharma Subject: Re: [PATCH v2] drm/i915: Replace kmap() with kmap_local_page() Date: Sat, 24 Jun 2023 02:10:56 +0200 Message-ID: <3747290.kQq0lBPeGt@suse> In-Reply-To: <20230617180420.GA410966@sumitra.com> References: <20230617180420.GA410966@sumitra.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On sabato 17 giugno 2023 20:04:20 CEST Sumitra Sharma wrote: > kmap() has been deprecated in favor of the kmap_local_page() > due to high cost, restricted mapping space, the overhead of a > global lock for synchronization, and making the process sleep > in the absence of free slots. >=20 > kmap_local_page() is faster than kmap() and offers thread-local > and CPU-local mappings, take pagefaults in a local kmap region NIT: _can_ take pagefaults in a local kmap region > and preserves preemption by saving the mappings of outgoing tasks > and restoring those of the incoming one during a context switch. >=20 > The mapping is kept thread local in the function > =E2=80=9Ci915_vma_coredump_create=E2=80=9D in i915_gpu_error.c >=20 > Therefore, replace kmap() with kmap_local_page(). >=20 > Suggested-by: Ira Weiny >=20 > Signed-off-by: Sumitra Sharma > --- >=20 > Changes in v2: > - Replace kmap() with kmap_local_page(). > - Change commit subject and message. With the changes that Ira suggested and the minor fix I'm proposing to the= =20 commit message, it looks good to me too, so this patch is...=20 Reviewed-by: Fabio M. De Francesco However, as far as I'm concerned, our nits don't necessarily require any ne= wer=20 version, especially because Tvrtko has already sent this patch for their CI. Thanks, =46abio P.S.: As Sumitra says both kmap() and kmap_local_page() allows preemption i= n=20 non atomic context.=20 =46urthermore, Tvrtko confirmed that the pages can come from HIGHMEM, there= fore=20 kmap_local_page for local temporary mapping is unavoidable. Last thing... Thomas thinks he wants to make it run atomically (if I=20 understood one of his messages correctly). As I already responded, nothing= =20 prevents someone does another patch just to disable preemption (or to enter= =20 atomic context by other means) around the code marked by kmap_local_page() = /=20 kunmap_local() because these functions work perfectly _also_ in atomic cont= ext=20 (including interrupts). But this is not something that Sumitra should be=20 worried about. >=20 > drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c > b/drivers/gpu/drm/i915/i915_gpu_error.c index f020c0086fbc..bc41500eedf5 > 100644 > --- a/drivers/gpu/drm/i915/i915_gpu_error.c > +++ b/drivers/gpu/drm/i915/i915_gpu_error.c > @@ -1164,9 +1164,9 @@ i915_vma_coredump_create(const struct intel_gt *gt, >=20 > drm_clflush_pages(&page, 1); >=20 > - s =3D kmap(page); > + s =3D kmap_local_page(page); > ret =3D compress_page(compress, s, dst, false); > - kunmap(page); > + kunmap_local(s); >=20 > drm_clflush_pages(&page, 1); >=20 > -- > 2.25.1