Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3402994pxf; Mon, 29 Mar 2021 00:58:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy37yUrnutNIVVWbVjn4SKqN0NWdd0++4KuJOIiUQ9FpaowvzJQD7fuLbOgZJkSx5IZJf1Q X-Received: by 2002:a05:6402:2070:: with SMTP id bd16mr27076244edb.133.1617004701840; Mon, 29 Mar 2021 00:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617004701; cv=none; d=google.com; s=arc-20160816; b=he6SYGkeNGYwb6MJ0CjtQHsAITgtqqhA/5g2eoAqVOYmBo8l4BKcH6EFbKeQ7NhCgN WHecfcGKuMGD0FUs+Mtr3MvvU1IoJDqO3Jrh0eomdrDI0SwI+tlmAqF5aeaMtyxdXNCi 4CkYtpQe86FqEDpjReIy6miBV7tzxSImzUvSssNdPeisxkG/4QqN0AalJeQMFItClhH+ vLcGKPLout6GbytuafW7xgi6zH+AbZ+Hk6ZvpRzVMbeQSaNDuvOFxZ2fD/rNTtZ6r3Zu VX+Nkdc4EwkUVokkIImdZjKAnqrQSuL2V+Qx8QhN06TDw22CsvnBdChwwjzZWfJ3uanU bAlA== 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=ekxLZHyslEMXUsCS9MVwJvaE/VW+Es4E7kHp3frilfQ=; b=ItRT/RzgfJnKtJFrTf4K0EOGRApfF+hplP2SvsPV8d++tZyKC/a3i0SGv76DgTA9qz cWKDtdDroCcV9ngei5BCLymufltnA8otUIT6yb4cean7MKiybfNXKaR4tyP/KaKRB4UW uRyC6Mv6wC6mW67wxtpCuNCrqG5k6OZM7uHyI2oAH/+rNX9gH90hdY2AXwXrk4gXVw+D u4ROR/OPk1OCbvx+znYXo/CS559Y1oYodMqlvy5EgCbBOZFya8bhebvbz8lCWaXp5zyA 5H9guiOdcAbdYkkNMB1gZ7IlrQq1bgjQo++2m1qgDAPjAoM1bXcwWerXe1sgHn7Ls8FP dpbQ== 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 b26si12701498eja.162.2021.03.29.00.57.57; Mon, 29 Mar 2021 00:58:21 -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 S230516AbhC2H47 (ORCPT + 99 others); Mon, 29 Mar 2021 03:56:59 -0400 Received: from mga12.intel.com ([192.55.52.136]:45546 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbhC2H4i (ORCPT ); Mon, 29 Mar 2021 03:56:38 -0400 IronPort-SDR: 204H9fM/sa1Hx08e6eWxIN5rufE+umgHijetPnNxs4aNCHaboqvKbXIcLFNFl4lxIeXsXB1R5f 4BvciCCMiHLQ== X-IronPort-AV: E=McAfee;i="6000,8403,9937"; a="170902063" X-IronPort-AV: E=Sophos;i="5.81,287,1610438400"; d="scan'208";a="170902063" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2021 00:56:37 -0700 IronPort-SDR: ZFyBHCYC06SwwoqQpsRe3C6SngPxBjApGKfIFwyAVOUAppYzUZaUydiczd9LUIYqCg84kg2TnR DQ4VenUd49eg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,287,1610438400"; d="scan'208";a="410960207" Received: from glass.png.intel.com ([10.158.65.59]) by fmsmga008.fm.intel.com with ESMTP; 29 Mar 2021 00:56:34 -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 1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model Date: Mon, 29 Mar 2021 16:00:39 +0800 Message-Id: <20210329080039.32753-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 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 --- 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(); page_pool_put_full_page(xa->page_pool, page, napi_direct); rcu_read_unlock(); break; -- 2.25.1