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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A92CC32750 for ; Tue, 13 Aug 2019 17:42:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D395A2067D for ; Tue, 13 Aug 2019 17:42:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727777AbfHMRmY (ORCPT ); Tue, 13 Aug 2019 13:42:24 -0400 Received: from smtp8.emailarray.com ([65.39.216.67]:29415 "EHLO smtp8.emailarray.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727942AbfHMRmY (ORCPT ); Tue, 13 Aug 2019 13:42:24 -0400 Received: (qmail 31791 invoked by uid 89); 13 Aug 2019 17:42:23 -0000 Received: from unknown (HELO ?172.20.41.143?) (amxlbW9uQGZsdWdzdmFtcC5jb21AMTk5LjIwMS42NC4xMzc=) (POLARISLOCAL) by smtp8.emailarray.com with (AES256-GCM-SHA384 encrypted) SMTP; 13 Aug 2019 17:42:23 -0000 From: "Jonathan Lemon" To: "Ivan Khoronzhuk" Cc: magnus.karlsson@intel.com, bjorn.topel@intel.com, davem@davemloft.net, hawk@kernel.org, john.fastabend@gmail.com, jakub.kicinski@netronome.com, daniel@iogearbox.net, netdev@vger.kernel.org, bpf@vger.kernel.org, xdp-newbies@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH bpf-next 2/3] xdp: xdp_umem: replace kmap on vmap for umem map Date: Tue, 13 Aug 2019 10:42:18 -0700 X-Mailer: MailMate (1.12.5r5635) Message-ID: <9F98648A-8654-4767-97B5-CF4BC939393C@flugsvamp.com> In-Reply-To: <20190813102318.5521-3-ivan.khoronzhuk@linaro.org> References: <20190813102318.5521-1-ivan.khoronzhuk@linaro.org> <20190813102318.5521-3-ivan.khoronzhuk@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; format=flowed Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 13 Aug 2019, at 3:23, Ivan Khoronzhuk wrote: > For 64-bit there is no reason to use vmap/vunmap, so use page_address > as it was initially. For 32 bits, in some apps, like in samples > xdpsock_user.c when number of pgs in use is quite big, the kmap > memory can be not enough, despite on this, kmap looks like is > deprecated in such cases as it can block and should be used rather > for dynamic mm. > > Signed-off-by: Ivan Khoronzhuk Seems a bit overkill - if not high memory, kmap() falls back to just page_address(), unlike vmap(). -- Jonathan > --- > net/xdp/xdp_umem.c | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c > index a0607969f8c0..907c9019fe21 100644 > --- a/net/xdp/xdp_umem.c > +++ b/net/xdp/xdp_umem.c > @@ -14,7 +14,7 @@ > #include > #include > #include > -#include > +#include > > #include "xdp_umem.h" > #include "xsk_queue.h" > @@ -167,10 +167,12 @@ void xdp_umem_clear_dev(struct xdp_umem *umem) > > static void xdp_umem_unmap_pages(struct xdp_umem *umem) > { > +#if BITS_PER_LONG == 32 > unsigned int i; > > for (i = 0; i < umem->npgs; i++) > - kunmap(umem->pgs[i]); > + vunmap(umem->pages[i].addr); > +#endif > } > > static void xdp_umem_unpin_pages(struct xdp_umem *umem) > @@ -378,8 +380,14 @@ static int xdp_umem_reg(struct xdp_umem *umem, > struct xdp_umem_reg *mr) > goto out_account; > } > > - for (i = 0; i < umem->npgs; i++) > - umem->pages[i].addr = kmap(umem->pgs[i]); > + for (i = 0; i < umem->npgs; i++) { > +#if BITS_PER_LONG == 32 > + umem->pages[i].addr = vmap(&umem->pgs[i], 1, VM_MAP, > + PAGE_KERNEL); > +#else > + umem->pages[i].addr = page_address(umem->pgs[i]); > +#endif > + } > > return 0; > > -- > 2.17.1