Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1381714ybl; Tue, 13 Aug 2019 11:35:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhdI7fCsTytRXn24iVNkuURftyxRyHAqCC8ufZdulidMOFoz31Mg+MdBORD8PBd3r++n6f X-Received: by 2002:a63:ec48:: with SMTP id r8mr34092202pgj.387.1565721321692; Tue, 13 Aug 2019 11:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565721321; cv=none; d=google.com; s=arc-20160816; b=AzxR9/lYgFUWFabFMnzZyLG9Wi4jiI+wPma6M2xAGs/GRsd+mmjoS/liZalVNanwau N3tnVrQayR9e6qge+J81PRg5p+rsdiCigP+/Pmm+gE9ri4sGD88C3p9jRQujazYH3LI5 ooIW2oIF0mt4tlCktg4TiHE3dQJ4thQBSHp3bLKqLXRS8IF2ICvxc6d0w2EqMbBMaQ+w RdkoAORGPvC2CgSZ/p0MtbMDlwCpSJoLA0Fho+aX2i1D0PpwqXCAXMwfZz3YeVI2erwS MytUdjSXWcxWehTbdX9a0L2T2JfmZgFgHej51fSvskDCZru377kVkcDayalFUYAZ99zk f9/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=w11YVFyoLhs+BNlDPKgWqoZJ95LEfsQBBxyoZnnFeNE=; b=IZC9uGuat+av7t7pSdaeL8bDGZArKzULc+pwc9ElxQBHQBCe+GmER/gnyfZm93Pvsj 0fxQ73GNhcg5BnJTON3DUJoQqDmYhurPVUYXrozCtWeEZgRGvGUuq3FHxOkTuxpwYmB1 fWxi3enSXxKzjUKdG4Mt05L33izEQrtFyPA+mevic0XoYJUdfEzYkwznr4VsI6UTuS10 nO6cSPpF3Ek+qvdBCnWdNl2HMhSJWDD62kKLTuyjy2CjfANS9bab9M1eltSG2pmJvsVz 3nu2yUcMxK5VVs+FDZ+qiC9VUt4bbPk1lHH4q267/u5Aevsliz/sRNjrTuJLV37xnQAH H+IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JXS1wIa7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r190si64615844pfr.102.2019.08.13.11.35.05; Tue, 13 Aug 2019 11:35:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JXS1wIa7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726605AbfHMSdW (ORCPT + 99 others); Tue, 13 Aug 2019 14:33:22 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34103 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726267AbfHMSdV (ORCPT ); Tue, 13 Aug 2019 14:33:21 -0400 Received: by mail-pf1-f193.google.com with SMTP id b24so1571953pfp.1; Tue, 13 Aug 2019 11:33:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version; bh=w11YVFyoLhs+BNlDPKgWqoZJ95LEfsQBBxyoZnnFeNE=; b=JXS1wIa7Asipg0jcfsj8uWKX+etctXxHpwJRJbAFNgqXrt3eObuuXS66gp5hdjk69D osQZW+muNqqcBsj2hwEsdy/Nic3Wk+eBkWjETfGIxD4ovlMjcFYwsHFw63/lv6h4Hcd2 Fhepa7HRvjRjKwsWNYs9tx2jo3v02jq68xR6Z0krWE4Qk3zyelI6wT/5jyvpKPJHok4Y Yk6ZMgkNKtK7qdbqgXAKWfhvCGhCxXl5QTBVxc+6O9ntTBXoUMD7Plf4DlDxz9rWzXh6 7RXgatQ/ExkJUVo62PW+mZ2UBlG7plWd91mSpeGLnnRWi6NuCjZcMW2oPvyCx1J1nhva 3zdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version; bh=w11YVFyoLhs+BNlDPKgWqoZJ95LEfsQBBxyoZnnFeNE=; b=gOIGgU21W6vSk4LlkPaO7JRZNG2p+y+uAFMk5RM2/mcH/ns6QwNsRe8+ovEkDc/PXn YiPmfO69HSf2FheC+PwkPeFJ6a+FhDXfj4/IyaGl0eqG1M8lSPvjRagbSa7mOAqlDrlN jBRDbPjFaP8MuHH+fwJ2qgo96H2RFw7mKZSmDGGgIrPqJjjUSVzpiOv9bP5NYpx5OXKb UVlSEKKrlSw+X4KmMb0xmRGLkFav0De4MlIAVCN0Ymx4gvQR/+YAMnMAY6FMoQdIuskK BjVeR8rrBeqRO/m3RQu4F7XTjlGtsFaAnc6jyHuZA1+mzQ0MomwV01c1tF0IR4kyv8Cc Bimw== X-Gm-Message-State: APjAAAVpH0lmqpQt3u1081voDHR59yMZee490dfGC8HTRFPbJtXUxIR1 ZOqkskxz2P1tOf1yPVqh63w= X-Received: by 2002:a65:43c2:: with SMTP id n2mr35769951pgp.110.1565721200412; Tue, 13 Aug 2019 11:33:20 -0700 (PDT) Received: from [172.20.41.143] ([2620:10d:c090:200::3:ec2a]) by smtp.gmail.com with ESMTPSA id b68sm134603729pfb.149.2019.08.13.11.33.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Aug 2019 11:33:19 -0700 (PDT) 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 11:33:18 -0700 X-Mailer: MailMate (1.12.5r5635) Message-ID: In-Reply-To: <20190813183023.GA2856@khorivan> References: <20190813102318.5521-1-ivan.khoronzhuk@linaro.org> <20190813102318.5521-3-ivan.khoronzhuk@linaro.org> <9F98648A-8654-4767-97B5-CF4BC939393C@flugsvamp.com> <20190813183023.GA2856@khorivan> MIME-Version: 1.0 Content-Type: text/plain; format=flowed Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13 Aug 2019, at 11:30, Ivan Khoronzhuk wrote: > On Tue, Aug 13, 2019 at 10:42:18AM -0700, Jonathan Lemon wrote: >> >> >> 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 > > So, as kmap has limitation... if I correctly understood, you propose > to avoid macros and do smth like kmap: > > void *addr; > if (!PageHighMem(&umem->pgs[i])) > addr = page_address(page); > else > addr = vmap(&umem->pgs[i], 1, VM_MAP, PAGE_KERNEL); > > umem->pages[i].addr = addr; > > and while unmap > > if (!PageHighMem(&umem->pgs[i])) > vunmap(umem->pages[i].addr); > > I can try it, and add this in v2 if no objection. Seems like a reasonable compromise to me. -- 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 > > -- > Regards, > Ivan Khoronzhuk