From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31739C7619A for ; Tue, 21 Mar 2023 15:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231858AbjCUPoU (ORCPT ); Tue, 21 Mar 2023 11:44:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231843AbjCUPoI (ORCPT ); Tue, 21 Mar 2023 11:44:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CF611E9CD for ; Tue, 21 Mar 2023 08:42:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679413360; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7/nQNcXvQOfjQfrlKnDNrxxtzxnlaUxAliAI/vatFyI=; b=VNByToXPhpQTDS6Ah7fJAP3womX/rC7RYWgmhET2pi1leURQlEPgkoDBXbxy+zGa5fIP50 HDdAXnoWsbyRdOXzpGWApgYG7+v80rUfIhhOo69jtQRxlGKcS48adGasH7fzksyndjovVU XmVoOcZiWhCJ9nDojrpxK96OQLkBzzI= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-637-Ln18TsOaMnSnU9CZS9zIrw-1; Tue, 21 Mar 2023 11:42:39 -0400 X-MC-Unique: Ln18TsOaMnSnU9CZS9zIrw-1 Received: by mail-wm1-f70.google.com with SMTP id m30-20020a05600c3b1e00b003ed31d151ecso6091084wms.1 for ; Tue, 21 Mar 2023 08:42:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679413357; 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=7/nQNcXvQOfjQfrlKnDNrxxtzxnlaUxAliAI/vatFyI=; b=8M6ZUbQBNA3JU2daI9oIs0fnWvR2Fb+ZyT4lBLwVJZ7gdmzIVBnQbiS+owmzq/1XEl YgeZSSWU/SwqDK52/RH4S0+Pe2v6p4bmecDRV/+zAGeoklx8Un5gSdR2+PL+WqajRpK0 eC78Fr2W8zlcmhLBjdyhQjsmR6AJUHqXWCZL9KgMs8U7P7lQdLFuzXwQy23osWoSoSQE uFrtolG12nuo6AmF1rxcxvG8vloY1Cx0rohqZGjSKpZLh/TWGxpdSikFgZwC4LP+xfSX LYJAUs8Clo0j9Pr4Oju3nIhqFHHVE75h8Vo4kg9v7lIFBv96vvMBSzVFrrXWRK3INAXj 5uRw== X-Gm-Message-State: AO0yUKWa/OKlrPq7Wd2rp3LYkj2xHJSPO+gMKovjsSxIFfosF0tAq7Tq xWf4U5khFgiv78tWvbgTsWdcYli6nxW+kOdFiFDEmwTRuxnRll6JqFC/o/v+vGAbMSUHKr4Humx 4TDL+0g+NvCJ3NtD10up/ X-Received: by 2002:a05:6000:10c3:b0:2d2:6a31:b868 with SMTP id b3-20020a05600010c300b002d26a31b868mr2602308wrx.27.1679413357316; Tue, 21 Mar 2023 08:42:37 -0700 (PDT) X-Google-Smtp-Source: AK7set/e7guuybvidSucOQAc9fidioCV858cDkY1wJhAUIbIQvY6mOovHetJt1xqlgoBWZ+wGjbLUQ== X-Received: by 2002:a05:6000:10c3:b0:2d2:6a31:b868 with SMTP id b3-20020a05600010c300b002d26a31b868mr2602288wrx.27.1679413357024; Tue, 21 Mar 2023 08:42:37 -0700 (PDT) Received: from step1.redhat.com (host-82-57-51-170.retail.telecomitalia.it. [82.57.51.170]) by smtp.gmail.com with ESMTPSA id n2-20020adffe02000000b002cfeffb442bsm11582490wrr.57.2023.03.21.08.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 08:42:36 -0700 (PDT) From: Stefano Garzarella To: virtualization@lists.linux-foundation.org Cc: stefanha@redhat.com, "Michael S. Tsirkin" , Andrey Zhadchenko , eperezma@redhat.com, netdev@vger.kernel.org, Jason Wang , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Stefano Garzarella , "Fabio M. De Francesco" Subject: [PATCH v3 3/8] vringh: replace kmap_atomic() with kmap_local_page() Date: Tue, 21 Mar 2023 16:42:23 +0100 Message-Id: <20230321154228.182769-4-sgarzare@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230321154228.182769-1-sgarzare@redhat.com> References: <20230321154228.182769-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org kmap_atomic() is deprecated in favor of kmap_local_page() since commit f3ba3c710ac5 ("mm/highmem: Provide kmap_local*"). With kmap_local_page() the mappings are per thread, CPU local, can take page-faults, and can be called from any context (including interrupts). Furthermore, the tasks can be preempted and, when they are scheduled to run again, the kernel virtual addresses are restored and still valid. kmap_atomic() is implemented like a kmap_local_page() which also disables page-faults and preemption (the latter only for !PREEMPT_RT kernels, otherwise it only disables migration). The code within the mappings/un-mappings in getu16_iotlb() and putu16_iotlb() don't depend on the above-mentioned side effects of kmap_atomic(), so that mere replacements of the old API with the new one is all that is required (i.e., there is no need to explicitly add calls to pagefault_disable() and/or preempt_disable()). This commit reuses a "boiler plate" commit message from Fabio, who has already did this change in several places. Cc: "Fabio M. De Francesco" Signed-off-by: Stefano Garzarella --- Notes: v3: - credited Fabio for the commit message - added reference to the commit that deprecated kmap_atomic() [Jason] v2: - added this patch since checkpatch.pl complained about deprecation of kmap_atomic() touched by next patch drivers/vhost/vringh.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c index a1e27da54481..0ba3ef809e48 100644 --- a/drivers/vhost/vringh.c +++ b/drivers/vhost/vringh.c @@ -1220,10 +1220,10 @@ static inline int getu16_iotlb(const struct vringh *vrh, if (ret < 0) return ret; - kaddr = kmap_atomic(iov.bv_page); + kaddr = kmap_local_page(iov.bv_page); from = kaddr + iov.bv_offset; *val = vringh16_to_cpu(vrh, READ_ONCE(*(__virtio16 *)from)); - kunmap_atomic(kaddr); + kunmap_local(kaddr); return 0; } @@ -1241,10 +1241,10 @@ static inline int putu16_iotlb(const struct vringh *vrh, if (ret < 0) return ret; - kaddr = kmap_atomic(iov.bv_page); + kaddr = kmap_local_page(iov.bv_page); to = kaddr + iov.bv_offset; WRITE_ONCE(*(__virtio16 *)to, cpu_to_vringh16(vrh, val)); - kunmap_atomic(kaddr); + kunmap_local(kaddr); return 0; } -- 2.39.2