Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1576656rwb; Fri, 23 Sep 2022 15:06:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Kf3MkSrZh2FGSO9YxnbgrLb8ijld3rNyAEObs9rVStw4NahjdeH8L2mrk5ETDe/IpC40E X-Received: by 2002:aa7:cd14:0:b0:44e:2335:fb90 with SMTP id b20-20020aa7cd14000000b0044e2335fb90mr10236276edw.152.1663970784628; Fri, 23 Sep 2022 15:06:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663970784; cv=none; d=google.com; s=arc-20160816; b=KqhEBX/BjArhs/StTD2sAbG1yINBTAMY1ionMC04NWLflFk/poQvhF6t33jCv9ZyYm avlykU351c0nVSwFAZZpvvk21wLgtTrs5Jz6erdC+Fjn4zzY9nQxcKqcCGJhJ6raaoP7 /rNgt8YcqyUBnw3DTBQshl61abeLsmhzlCro7APhj0ZX/ulsteQLbAwUQUptAN9rFmOr tZVQct3HSGWKJmIul9N2+WimcQRmPF3Z5j2yohtN9WJTafGVupRuqyYbAUhy7iGmCVrR lYicM7E7mW/xeoRmOkfk+OtLEyjmvwt8d2gfrN+Q61OHq26H1EJsCuGef9jDWrw68jjT V0VQ== 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=onRZypm85DpA8F8xppQeAp1Vjn+WOvdDaZWVxEq3cLc=; b=k0Z/mv6rcMXVv3OUUCicprCzEXbp6HFV+scnom4HdB6D42k6pFY8cebPbp1JJM7aJ1 FJQbeYEVR3+Sq8OgMaOaWkRw5NHY72OvosvuqzcVeYRxirdKIqw7JA/6WfVLHB2ej4+w WbJtI5imz7C9F1WBmvO7KqB347yD2NEtRWBm2srzTjWXCnQYhmbS5ytUPNUNChIeVGCz SSiL+wNXf0VFmsadzVxjgtWESLTRXV5AqBVJ2FkA/53b1Ieh5C1ze1XendSI6eYtNoKP KFOMCj4O0B1RTQcm9hREoCh1mgf4J6tRwajofbtI1mJmPy4T2zKh32kJFNV/U7ADXwxy pOwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AeUNuttH; 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 ne35-20020a1709077ba300b007823edcf3dbsi7699944ejc.19.2022.09.23.15.05.59; Fri, 23 Sep 2022 15:06:24 -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=AeUNuttH; 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 S232783AbiIWVb4 (ORCPT + 99 others); Fri, 23 Sep 2022 17:31:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233008AbiIWVbR (ORCPT ); Fri, 23 Sep 2022 17:31:17 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A5D8B6D1B; Fri, 23 Sep 2022 14:31:15 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id c7so1355275pgt.11; Fri, 23 Sep 2022 14:31:15 -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=onRZypm85DpA8F8xppQeAp1Vjn+WOvdDaZWVxEq3cLc=; b=AeUNuttHkTaoXwu2MlIkDD2woBAl8avyM41dVZduixGhJTCYnqihozhDNDuvmvRqbu +u0g4u3ztcyq2l97S51FzEVJhiwGEt9SBftjI8gKnb6sZY1EzYZkeKvEwMyqgWKyXwJG ZjlRrhe9fVXoE8B1bVn3qhbZAdSNoUKZBqa8zpBBn/m4qIkT/y4hnFnRkUg+jRmH4gp4 BKG8PYXtMccnfGNFz5UVvPv9kC853jR7svR1stpYtYmuTIgpRaG1ISQsbE4h+ftIcV48 2z+V+d/75k/6aacdfZnoe73t9ciMSNCt5LxEhZRHuTDpiBJBbtEjAmBdt5J5H6pwuZjw Ykpw== 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=onRZypm85DpA8F8xppQeAp1Vjn+WOvdDaZWVxEq3cLc=; b=0JClvZcGxumQsR/nlUwhl533KEaiqe4heSjZKsOHH8breUNYNKb3CisJX4O8Eps2B0 N76YpmSbI303cguMLVHzS5Ac7UDyMldw0+V8xIub1HfWvXX/WO1oh1EKlmhrUHuPnamP Fv3Id66fsrW5iRhaAsdm8EKmaTVOB+srFWjIHmcLw6If/TZHj0CSO7P78Il34Tabm7M2 +7h/jZDBVL4sH0dZzDhGMj3BnF/+v1i1qf5qhULpyEVfe9omOvc/5F8a4LtFuTCErWgW mW9YId+paqmKLbGGXu/huQSvYhqze6gsy31wFTG2yByUdyRpL6MkOKwpaBAYK8WFjLU9 tXyg== X-Gm-Message-State: ACrzQf3HxvXwpQ0fGMZcyjTO+YKaG/BUbpbw4W3PHc/GUA6dOqyKi3NA 9VK46AhapYdK16qvDACNR5da7HTrJlSva2nuqws= X-Received: by 2002:a05:6a00:a95:b0:547:b3e0:b1c0 with SMTP id b21-20020a056a000a9500b00547b3e0b1c0mr11273947pfl.53.1663968674771; Fri, 23 Sep 2022 14:31:14 -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: From: Alexander Duyck Date: Fri, 23 Sep 2022 14:31:03 -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 Fri, Sep 23, 2022 at 11:51 AM Anirudh Venkataramanan wrote: > > On 9/23/2022 8:31 AM, Alexander Duyck wrote: > > 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. > > Well, my understanding is that kmap_local_page() doesn't have the > overheads kmap() has, and that alone is reason enough to replace kmap() > and kmap_atomic() with kmap_local_page() where possible. It has less overhead, but there is still some pretty significant code involved. Basically in the cases where it can't bail out and just call page_address it will call __kmap_local_page_prot(), https://elixir.bootlin.com/linux/v6.0-rc4/source/mm/highmem.c#L517. > > 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. > > I don't really see this as "pulling the kmap() bandage", but a "use a > more appropriate kmap function if you can" type situation. My concern is that it is more of a half step in the case of the e1000/e1000e drivers. We likely should have fixed this some time ago when I had rewritten the Rx path for the igb and ixgbe drivers, but I just didn't get around to it because if I messed with other areas it would have required more validation. I'd rather not carry around the extra code or function calls if we don't need it. > FWIW, I am not against using page_address(). Just wanted to hash this > out and get to a conclusion before I made new changes. > > Ani I gathered as much based on your other conversation. This is essentially the module-local case you had referred to in which the page is allocated and used within the module so there is no need to be concerned about it possibly being a highmem page. Thanks, - Alex