Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3717653pxf; Mon, 29 Mar 2021 09:29:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwn8CL21B1yLS1b+ABx8a5saAAAOIgxpg9vxw8/WxTzpyDAqSopNGtVDQ6orhgPQxcNGvai X-Received: by 2002:a17:906:b80c:: with SMTP id dv12mr29572266ejb.110.1617035341847; Mon, 29 Mar 2021 09:29:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617035341; cv=none; d=google.com; s=arc-20160816; b=HAVmes9zqFpOFLfFVE2S4IrjZs7/dStmznk5U8Cd1qZmg7aRU6hhkIw33FYcmve1bm lyS5ZilLFmy6yWhmjfKYnTo2KFEA/5QIbr5+10zLIQF2us5S/w8PPrFhZ9MqFwVoDvxe q3vb9j5cbl1CkvnEIjclucshIE8UVFko92xDFecd5MAmGBZIOu5kCp+83jheu8rKzBMY W5BOqarB+Hr53qbVchWmFMV6C0otpCT8g1ksmQbOltZjgKtxysOu+j3qxXqqezIoGL0R CUF2YWTLSlv1HGobDVkAowuhIHQRucfFwSBm25nYMe+E2uS1lUow5dj9KK9qzYjLCJRB dwyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=mbFIhCPku9MFTnIxaRhUC4X/zn411dNU5tYynxv/ZoU=; b=WstCvkcS9TiD/YBsGc7fL4g0gynsELMOLvFX186YoAWkRUeQqvz+KrWiJTxXn2xT0k 2AXyifJt7tXUtUUZs/ZSDHBmSXEEcYZZXRczzUkbmAKD0YCtERYc86hpLMON6z6TOqmV 5XzGJWur6BEpVFbYQ/vJNqWZJRrKOyqls0rP9rOi+M4fZVJg+euZOdmkWE2If6aAUYuW V+jq3HldSQzikGgn1yjeALluoMMaADlEC6vfbeyfQQccj9KaYctVFnsRu4OLL6CrHKaV ZpHpqGeXvczYcy/3U3yHKT+jaBczMGUXCDeUxYwUibE3HYdrePMahxko5Fm3ofAAHEFK 8MYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OKEbGMmB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si13017482ejw.650.2021.03.29.09.28.38; Mon, 29 Mar 2021 09:29:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OKEbGMmB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbhC2QZg (ORCPT + 99 others); Mon, 29 Mar 2021 12:25:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51301 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231649AbhC2QZQ (ORCPT ); Mon, 29 Mar 2021 12:25:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617035113; 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: in-reply-to:in-reply-to:references:references; bh=mbFIhCPku9MFTnIxaRhUC4X/zn411dNU5tYynxv/ZoU=; b=OKEbGMmBikCLaew/FcuGEdteEgxlMKvgTSHDil00nSByn+iENGeWGVMc7Oe753L5kXj/tT jC/NzwEusPA6WHWJ6jWZsxZ7AmtdeDl5/d0orgSEcCiK0OddYkLDW03hCC+E6BmsW4JxqM F9TKlYwhAFaTd+DWxqIjoIG4r7FWWh0= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-399-qOruQgiyNGW82h5Jfle3-A-1; Mon, 29 Mar 2021 12:25:12 -0400 X-MC-Unique: qOruQgiyNGW82h5Jfle3-A-1 Received: by mail-ed1-f69.google.com with SMTP id w16so8852863edc.22 for ; Mon, 29 Mar 2021 09:25:11 -0700 (PDT) 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:in-reply-to:references:date :message-id:mime-version; bh=mbFIhCPku9MFTnIxaRhUC4X/zn411dNU5tYynxv/ZoU=; b=pkJSt6LMFZtKiTaeFB7TI5rZiikl2HATt+PE9s9cQHpZrGWZ7F6WQEkHWddpnKRd5o deRaIp2FzfsXHOnVZJgTC1xG5FsZJecCwhbGr/polAFzKV0shiqh+l83Y2wdYZ8Azmcf RatNPvnQ0FxZuQhv+o4rgX2QQp6yKIbkTlvRluh/RQUXz5hDT7YN2fTK/GodkVSx5Mhy Z4o/u+KpVrQgiMrhKdY2uSys/3zev6cqGkcBFT7mwZVxCPuxfa2k7wCl9eJ+T2r9hiEc xT1FsoFyB+HYIUDZopdoRI1vzSfKalpDSjLA4DBZlac+n8z2G8M7M9t6aJOSY+eT8Y4f H8cQ== X-Gm-Message-State: AOAM533/eSeMdeDCR81OcllG80IrRSbTSdfZAWgixArUWw8Fi57jRFoP I7wgu3C76yLqrGPhrvLhQzAMHtHiotX/AiivKLE7dPujQpVKW6mL4eO4iDg9t3gmrP5mUr53y9z pSXwetsp03cqC8TQ4TSk4c+9r X-Received: by 2002:a50:ec96:: with SMTP id e22mr29345932edr.385.1617035110007; Mon, 29 Mar 2021 09:25:10 -0700 (PDT) X-Received: by 2002:a50:ec96:: with SMTP id e22mr29345921edr.385.1617035109876; Mon, 29 Mar 2021 09:25:09 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id cw14sm9522115edb.8.2021.03.29.09.25.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 09:25:09 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id AC9F6181B24; Mon, 29 Mar 2021 18:25:08 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Jesper Dangaard Brouer , Ong Boon Leong Cc: brouer@redhat.com, Alexei Starovoitov , Daniel Borkmann , "David S . Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Toshiaki Makita , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net 1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model In-Reply-To: <20210329170209.6db77c3d@carbon> References: <20210329080039.32753-1-boon.leong.ong@intel.com> <20210329170209.6db77c3d@carbon> X-Clacks-Overhead: GNU Terry Pratchett Date: Mon, 29 Mar 2021 18:25:08 +0200 Message-ID: <87lfa6rkpn.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jesper Dangaard Brouer writes: > On Mon, 29 Mar 2021 16:00:39 +0800 > Ong Boon Leong wrote: > >> xdp_return_frame() may be called outside of NAPI context to return >> xdpf back to page_pool. xdp_return_frame() calls __xdp_return() with >> napi_direct = false. For page_pool memory model, __xdp_return() calls >> xdp_return_frame_no_direct() unconditionally and below false negative >> kernel BUG throw happened under preempt-rt build: >> >> [ 430.450355] BUG: using smp_processor_id() in preemptible [00000000] code: modprobe/3884 >> [ 430.451678] caller is __xdp_return+0x1ff/0x2e0 >> [ 430.452111] CPU: 0 PID: 3884 Comm: modprobe Tainted: G U E 5.12.0-rc2+ #45 >> >> So, this patch fixes the issue by adding "if (napi_direct)" condition >> to skip calling xdp_return_frame_no_direct() if napi_direct = false. >> >> Fixes: 2539650fadbf ("xdp: Helpers for disabling napi_direct of xdp_return_frame") >> Signed-off-by: Ong Boon Leong >> --- > > This looks correct to me. > > Acked-by: Jesper Dangaard Brouer > > >> net/core/xdp.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/net/core/xdp.c b/net/core/xdp.c >> index 05354976c1fc..4eaa28972af2 100644 >> --- a/net/core/xdp.c >> +++ b/net/core/xdp.c >> @@ -350,7 +350,8 @@ static void __xdp_return(void *data, struct xdp_mem_info *mem, bool napi_direct, >> /* mem->id is valid, checked in xdp_rxq_info_reg_mem_model() */ >> xa = rhashtable_lookup(mem_id_ht, &mem->id, mem_id_rht_params); >> page = virt_to_head_page(data); >> - napi_direct &= !xdp_return_frame_no_direct(); >> + if (napi_direct) >> + napi_direct &= !xdp_return_frame_no_direct(); > > if (napi_direct && xdp_return_frame_no_direct()) > napi_direct = false; > > I wonder if this code would be easier to understand? Yes, IMO it would! :) -Toke