Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1189061rwb; Fri, 23 Sep 2022 09:14:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6NaMpiyboduiOhAYHwAZnBLPHrOfLjkZSd6o/5DF9CGJSHo1tOjQBA392G1fdrgdBjVGd7 X-Received: by 2002:a17:90a:6c45:b0:202:7883:5239 with SMTP id x63-20020a17090a6c4500b0020278835239mr10383453pjj.225.1663949670864; Fri, 23 Sep 2022 09:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663949670; cv=none; d=google.com; s=arc-20160816; b=ujNQ2/9dTP2w48aZROp7wiYdehU9J6HGBURgf1XxaxVj28vAvqZJOqXz2Cls8odgRS U9GYqekR5a6cE+MAwuFD4m9dbWP57APg/ZWnhD1Q2q0uSJbvahqNhn/STvmTTvMcIKq5 MSXTFoL8IqxJdvNGCJqN4Ap5XymwPwbfha8K8NLjpB/oZu9SDe5LR9sE4lh1idtrTspq H5NnLZqmyz6OJVxvPLcT6ahJqwNxM045PPqlTGW1YMe+cJzsZagOfEosTgR/XCFPnl9a 8QXLqre/1I7HGiHyk9Fxtx9IkUbM3gFbD+FT7KtIYqZ/nZmTb5IdrtQ3+4bvwvfbeQJy LiuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Xe3XyWrqsUpCuai4jbPz6/cvFb16oXvZzjUKpqqt2d4=; b=WnN62/OUCMlhw2bXkLr5cdr3duYulZR+Oi+yKFpF2IekG0l7Dgu8mO+LidQOLUPRrk 3V9Vu5lyvTSgvcKMcVWNKOi5s2RukIAV9yXVkMmvUiXSZjJje9gz5pi7IlJte9U/H3zc MXeJ30rNPk0eluJKzngmo0hqHwgB+1UOOD3EJNlbtDb/rbrcALA2pjtoOdbSxYPGrZYn wniKL0pQ69SW6azIIlJU6HW01z3yEuVim/Lx8K9Ms8ZE7M604y+aVhDEnrIE+nVpe86Q DeN4xHBtc5FiQpR20yvXvszvg1PDg2cqMD1uSeX1/C/HMhUPvmlXaOh8ZCyia/d9QK4g da+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pdNyL0WG; 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 d14-20020a056a0010ce00b0052abf46260dsi10123994pfu.25.2022.09.23.09.14.17; Fri, 23 Sep 2022 09:14:30 -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=20210112 header.b=pdNyL0WG; 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 S232645AbiIWPcN (ORCPT + 99 others); Fri, 23 Sep 2022 11:32:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232568AbiIWPcK (ORCPT ); Fri, 23 Sep 2022 11:32:10 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4F66143540; Fri, 23 Sep 2022 08:32:09 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id s14-20020a17090a6e4e00b0020057c70943so6205532pjm.1; Fri, 23 Sep 2022 08:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=Xe3XyWrqsUpCuai4jbPz6/cvFb16oXvZzjUKpqqt2d4=; b=pdNyL0WG+TM+D2OmwmHa3lgy/2qVjYEs4ma7S6GPiljI/h7J9uxrTXIshJRZpTLyuJ ADWNh/ennmmb5VuiZpuAjpfHrNtRXWUOPRTPO86XNjnUG9DHyQUULWRMgqXv+2WL82Cg A56cuv7CO7EIUZzobvZrcVWFv+oDKnO3hsEAHT8bCA3/yerqPfI3FfKHgSkQuIoMnQGs tICn+DKO3AjWeYOTBD1eOiYb8r6HQXJzF8g1Q9AU2n+SzCRG9OdMigh3MHDFApr7WSi0 ifOEgu5qyTNdiMGfQbnSlqDBSOJsbnsJwzt58BwC7CAo461hl7d8VvcDiTIP2/1fOHFX EgGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=Xe3XyWrqsUpCuai4jbPz6/cvFb16oXvZzjUKpqqt2d4=; b=lNXnufxcrQ08zb+ma9TyyfdFXxvRA+jvUvHraw2fiJ4mfZAwc8GXhzQMPB37/R77Kp si9nqrKn55yhaPguvaTi8/C8OYKsMu2ZTTeEi4haESZLmNZBc01wJPE0mvFKhO3Ydx7z XjelbvBcsSjvbQlkd9xTEh4YvRflwAXcLGc5xvvMiFFH0N3nsMf3cjqFw7vNc7RjVr8T J+/yuJ6ubQbhPEDy4nhJ7EZy8hR3lOLlu2WN9MQ79x24Wz4RvFIpz1pGVQQbgj3MPOQ1 jLvFa5jn9gw6Zqz0ZJEksNi2sUIGDX3YHWlaMIjRdAYXS9lnGPcNiPfbUQtQ+/8t7KAX 6WfQ== X-Gm-Message-State: ACrzQf3IvetCVuHBRj6S++WF66t/Iz/4VU+UymMK+UvCQp+IV86cQAz0 BtCiePtP2DdVFK8iKa9mb0XsYyUjXG3HXgw1KYc= X-Received: by 2002:a17:902:e353:b0:178:77ca:a577 with SMTP id p19-20020a170902e35300b0017877caa577mr8883901plc.93.1663947129142; Fri, 23 Sep 2022 08:32:09 -0700 (PDT) MIME-Version: 1.0 References: <20220629085836.18042-1-fmdefrancesco@gmail.com> <2254584.ElGaqSPkdT@opensuse> <2834855.e9J7NaK4W3@opensuse> <22aa8568-7f6e-605e-7219-325795b218b7@intel.com> In-Reply-To: <22aa8568-7f6e-605e-7219-325795b218b7@intel.com> From: Alexander Duyck Date: Fri, 23 Sep 2022 08:31:57 -0700 Message-ID: Subject: Re: [Intel-wired-lan] [PATCH] ixgbe: Use kmap_local_page in ixgbe_check_lbtest_frame() To: Anirudh Venkataramanan Cc: "Fabio M. De Francesco" , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Netdev , Maciej Fijalkowski , Jesper Dangaard Brouer , Daniel Borkmann , intel-wired-lan , Alexander Duyck , John Fastabend , Jesse Brandeburg , Alexei Starovoitov , bpf , Paolo Abeni , Ira Weiny , LKML , Tony Nguyen 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 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 Thu, Sep 22, 2022 at 3:38 PM Anirudh Venkataramanan wrote: > > On 9/22/2022 1:58 PM, Alexander Duyck wrote: > > On Thu, Sep 22, 2022 at 1:07 PM Anirudh Venkataramanan > > wrote: > >> > >> > >> Following Fabio's patches, I made similar changes for e1000/e1000e and > >> submitted them to IWL [1]. > >> > >> Yesterday, Ira Weiny pointed me to some feedback from Dave Hansen on the > >> use of page_address() [2]. My understanding of this feedback is that > >> it's safer to use kmap_local_page() instead of page_address(), because > >> you don't always know how the underlying page was allocated. > >> > >> This approach (of using kmap_local_page() instead of page_address()) > >> makes sense to me. Any reason not to go this way? > >> > >> [1] > >> > >> https://patchwork.ozlabs.org/project/intel-wired-lan/patch/20220919180949.388785-1-anirudh.venkataramanan@intel.com/ > >> > >> https://patchwork.ozlabs.org/project/intel-wired-lan/patch/20220919180949.388785-2-anirudh.venkataramanan@intel.com/ > >> > >> [2] > >> https://lore.kernel.org/lkml/5d667258-b58b-3d28-3609-e7914c99b31b@intel.com/ > >> > >> Ani > > > > For the two patches you referenced the driver is the one allocating > > the pages. So in such a case the page_address should be acceptable. > > Specifically we are falling into alloc_page(GFP_ATOMIC) which should > > fall into the first case that Dave Hansen called out. > > Right. However, I did run into a case in the chelsio inline crypto > driver where it seems like the pages are allocated outside the driver. > In such cases, kmap_local_page() would be the right approach, as the > driver can't make assumptions on how the page was allocated. Right, but that is comparing apples and oranges. As I said for Tx it would make sense, but since we are doing the allocations for Rx that isn't the case so we don't need it. > ... and this makes me wonder why not just use kmap_local_page() even in > cases where the page allocation was done in the driver. IMO, this is > simpler because > > a) you don't have to care how a page was allocated. kmap_local_page() > will create a temporary mapping if required, if not it just becomes a > wrapper to page_address(). > > b) should a future patch change the allocation to be from highmem, you > don't have to change a bunch of page_address() calls to be > kmap_local_page(). > > Is using page_address() directly beneficial in some way? By that argument why don't we just leave the code alone and keep using kmap? I am pretty certain that is the logic that had us using kmap in the first place since it also dumps us with page_address in most cases and we didn't care much about the other architectures. If you look at the kmap_local_page() it just adds an extra step or two to calling page_address(). In this case it is adding extra complication to something that isn't needed which is the reason why we are going through this in the first place. If we are going to pull the bandage I suggest we might as well just go all the way and not take a half-step since we don't actually need kmap or its related calls for this.