Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp414277pxf; Wed, 31 Mar 2021 06:40:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyloBKVXxru0jlD8h10V9AIciTo7nVuBIUrKEFyVqPiFXYRqg5Es7CX2Jaaj+6VtcN30Rqa X-Received: by 2002:a17:906:fcb2:: with SMTP id qw18mr3480256ejb.434.1617198013965; Wed, 31 Mar 2021 06:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617198013; cv=none; d=google.com; s=arc-20160816; b=DIoFf0zfayodmYWFDD4OQ38PlsAD8n0wwuTMkokOyDd7N3WujhVv8+alutc3bRK+zZ mbf1i/+N/P9QIdOzcv807GOSQpDEeJJCwggg7vUQQUPbboDDSbg3vRMqTfte20c20kp0 2s8HZWkvtLlAZ1ihnATZTHResdYS9hvKU0eezTSd6mfmNpMlnwLgY+ij7xU67S6/IWpX vdWI+9Qhoqsa4OHOmaHPqPXdwLgTByGrhF9KxY2OBNcvt3YwJ2WAShwlQO0BhcWCSqyY p9Bsl/YUJpmy7L6QAP9+Aaw2AmUxxBwcY8d4XMMTV6bkCJbd1pJ+ALVFgFNa1CXOySpF b6pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=8YS4poPAZCHByMf0w+dOhsWCqsrYJ+hqPkfQ8CKmtvY=; b=EOUnGFqeXH9TifM08yZBh/KaRBYVzbZgMnZsod88Lht5GHtxg5z7pt778YU0PVT0gr WY3vvtSMRszm52aYY4SSObWjQ8RtMILyxldsig9dtRosKNYFsgtYU05qoDyZ4vaGw8dH ZU4T4NHYha/hWp0cK2hcjFX7ZL3YrlUZ9ne/bD4MUgNXYaEHwrxO3squx+1UQsaQFmqF Y5jqo6E/sMEy0MD0Gp0SnCxsfJwkPORzAUY19zcLocB5/NztA5JOEoyurvwDp2atH/rd Sg/W3M42XHr4MbWyJQSmb6fY6aJZKGpMZPk3kDiLQmY5ygelRTy37iC8mnm4w+kbR9l2 NN8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MZ4W5r1z; 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 p8si1888704edm.44.2021.03.31.06.39.51; Wed, 31 Mar 2021 06:40:13 -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=MZ4W5r1z; 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 S235843AbhCaNiU (ORCPT + 99 others); Wed, 31 Mar 2021 09:38:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45774 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235796AbhCaNiT (ORCPT ); Wed, 31 Mar 2021 09:38:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617197899; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8YS4poPAZCHByMf0w+dOhsWCqsrYJ+hqPkfQ8CKmtvY=; b=MZ4W5r1zLaCS99Ja11yv+QyV8cewhhXhAY6mJn2/hO/+3gYVDDMnz4r+5zrENDFSijg+ll eHfokeCaXSHBS7zCzpkuxn/tDdv88BYNR4a8EBJEFbGwcP6MagjTfYb8+7E6yc+1cGOqFh Pv09gEUCd/W5pCMx63N/7M/CzrJSyo0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-aBp1IZDWPqeqKr_xPiJwCw-1; Wed, 31 Mar 2021 09:38:13 -0400 X-MC-Unique: aBp1IZDWPqeqKr_xPiJwCw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8C21A84B9A2; Wed, 31 Mar 2021 13:38:11 +0000 (UTC) Received: from carbon (unknown [10.36.110.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C59460C5A; Wed, 31 Mar 2021 13:38:04 +0000 (UTC) Date: Wed, 31 Mar 2021 15:38:03 +0200 From: Jesper Dangaard Brouer To: 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 v2 1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model Message-ID: <20210331153803.38fb83de@carbon> In-Reply-To: <20210331132503.15926-1-boon.leong.ong@intel.com> References: <20210331132503.15926-1-boon.leong.ong@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 31 Mar 2021 21:25:03 +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 > > Changes in v2: > - This patch fixes the issue by making xdp_return_frame_no_direct() is > only called if napi_direct = true, as recommended for better by > Jesper Dangaard Brouer. Thanks! > > Fixes: 2539650fadbf ("xdp: Helpers for disabling napi_direct of xdp_return_frame") > Signed-off-by: Ong Boon Leong 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..858276e72c68 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 && xdp_return_frame_no_direct()) > + napi_direct = false; > page_pool_put_full_page(xa->page_pool, page, napi_direct); > rcu_read_unlock(); > break; -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer