Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp401214pxf; Wed, 31 Mar 2021 06:22:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0zVCZbUNHX0CV35W7jzDiLjSHor58Xn27tTMRnVWpXmQTZKrzOm3/1W6sFz6ha0W0jKpG X-Received: by 2002:a05:6402:4a:: with SMTP id f10mr3641074edu.85.1617196961424; Wed, 31 Mar 2021 06:22:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617196961; cv=none; d=google.com; s=arc-20160816; b=EkdRaRyb30kmtFI38FmGBFicSLKpJE0Dlr4nUir7t4wew9s0C/7IzTJOKkvtR/4NfN hv4u7E88f2YVIeCD39blADmCueAv2iFLLhLH9mdQm8stlMpQYWb2fX6/1hbwktuL2Ysh 23Cgat6D/e5b8/9PJv9QVSHsT++W5ntybVp8SXIHgKRkCWBanwBtUfLA5Ip+XR3dKESR LMRnNGcGL6IqiveO4YXji6dqWhOg3PPZBcgly4BeWJlit+FsuERUpdvF+qT57RSzb5oC xiAoTV9aqL+IfpEXNNSpWFK1sQccPQ+YGPK/eIKSsF4b+3FnLA+AhIixaz/qTi+qZh/f R7ng== 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 :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=fcdxyEwWMNCW3gqed4cJAPwHrAGZAUEpqMnIQ2sRFjM=; b=H3GWTHqRNqDc+MVwC2s8JsQQbJvgnN5/MvSO80TcoCc4O13kTfqthUcFbULlu0QqXk YZdAtpxfuD+GFrb0xsPG1zglYCo5n05KrBYBWSVDvUI2rs4eSce7ZWRI7s20I2J+QmTc vOiEhesgYVaMsuFk9MH2KQnS+p9d6lV9PNR446S2XG8bMdQrSHvEo+VT/kyv+f9eqVIi +yzcp1DMe3BIuiyjoBw8P6Qv4evImJ7OAwODmdx8Lgf5BHWkq+l4dfVXszZNIygGo2pS a3h657kR8qh1IXcyd8QZFm+P/670tAXLdyLDxVXUeQDsTnlf8EQTEJpsuvjTVRnLIJF1 W8Cg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hb26si1582266ejb.144.2021.03.31.06.22.17; Wed, 31 Mar 2021 06:22:41 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235792AbhCaNVU (ORCPT + 99 others); Wed, 31 Mar 2021 09:21:20 -0400 Received: from mga05.intel.com ([192.55.52.43]:41730 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235347AbhCaNUw (ORCPT ); Wed, 31 Mar 2021 09:20:52 -0400 IronPort-SDR: Co7vcJdY3iZW0HR4nse/aAmEQGH4Yb+2Q7Dm8VAKsqqbjL1ukE2i+UVAKZ5W0C+1iCXu3c22p6 4VozuV6ii5Dg== X-IronPort-AV: E=McAfee;i="6000,8403,9940"; a="277184483" X-IronPort-AV: E=Sophos;i="5.81,293,1610438400"; d="scan'208";a="277184483" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2021 06:20:52 -0700 IronPort-SDR: XPkYDsek3QTykAZNgPrvVhgFyXkyxZa0cVvA8VCGZQMQWBKGNP5JB5vxjT7c6NjuJGqCQIlVF+ kzSdoBGRd46A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,293,1610438400"; d="scan'208";a="455482204" Received: from glass.png.intel.com ([10.158.65.59]) by orsmga001.jf.intel.com with ESMTP; 31 Mar 2021 06:20:49 -0700 From: Ong Boon Leong To: Alexei Starovoitov , Daniel Borkmann , "David S . Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Toshiaki Makita Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Ong Boon Leong Subject: [PATCH net v2 1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model Date: Wed, 31 Mar 2021 21:25:03 +0800 Message-Id: <20210331132503.15926-1-boon.leong.ong@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; -- 2.25.1