Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3657123pxf; Mon, 29 Mar 2021 08:04:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKwE0M7rsYN73hF9KwRvYNcwvhz6r9q6BAFZR2whDi5SHUQypcXm4qAwX1ynDzedWw5EiV X-Received: by 2002:a5d:518c:: with SMTP id k12mr29227984wrv.15.1617030265630; Mon, 29 Mar 2021 08:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617030265; cv=none; d=google.com; s=arc-20160816; b=LfyfTCUq/eS9H9MVi1GkLiPdC+B5e9mvNk66VbthkZQtTvmR8Fxl0PIBBYfGwADruw 63/9SYMIeBGi0twDx2JYytxgTF0p8E8nppeVZjNbxIXDlIbkMzl9NdClclfnLckpytwo l9+HlYbz8d1V2KdgSMLR299IwYE3wCFGIksDqfEQA8q3QxK3jcJIf5OVR08hOKBxxDfF +JOmZsGmILwI0LJ8cy4E9fzMsnpHZ19oJCtJKD2NaqObms9ZMwFtNyFRy00MFARuXYYv bGCsrcmPf0+bTc6R6tdLcvcoGWDI70l5wrbZmn37Xl99B2Ne0EjSPDeRd6gTAQ9g87oT F/4Q== 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=GpUyjXYad8Nke0gscTyFnkIrJ5zuAIffuUq3tkDKdHk=; b=fSAIzlWovCV2RGoHkr++LtkHDsFWBLVfnUDXtKnt5KVx2Sn/9lKapsz72HQKQYMDq8 kimsdpquAzwmf0S21DI8wQ5M2YoYal1S3P7TgTO5908D3ZT7Zslml+F9G0Hkqy7R1lTS jKCqN890ilOp5MOXKSl4dL1Wro+R+yOYXIIwRo+LRsRWXN57pIyitDJeEHF3ongZCTUV d/a7JaNBURD1QSx0j8gxqfik3ZrBsB/A8lryhXW+YpPRP6Nqmb4QY87BM69jyjtgC5+B YbmaWdEEkIm52yt3VICS7+WM7n2YrZEsxx2d/qttC1Zctnb7luvQZV1ZxI9aZGK8wW9j I3ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="MlpQheD/"; 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 s10si13573143edi.563.2021.03.29.08.04.02; Mon, 29 Mar 2021 08:04:25 -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="MlpQheD/"; 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 S229555AbhC2PCk (ORCPT + 99 others); Mon, 29 Mar 2021 11:02:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35526 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbhC2PC0 (ORCPT ); Mon, 29 Mar 2021 11:02:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617030145; 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=GpUyjXYad8Nke0gscTyFnkIrJ5zuAIffuUq3tkDKdHk=; b=MlpQheD/A5Rt+RgfvgU4nA4URIB/zPw3FOj1OY2UfkYtl60TwVQkS9IZWj/2QkyOmRNIoM x4Fn0xVG1vB81AMfEwx6n0vETttPc/7wu6l3BvpH81SzI3MtHenVJtt81T9yx+6tkFJAZU ZTOTyQ3n4eRtIUPqTtqDubwbBw/ehfE= 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-541-Z6c1VwrFO-6VsSD9oW6rIA-1; Mon, 29 Mar 2021 11:02:20 -0400 X-MC-Unique: Z6c1VwrFO-6VsSD9oW6rIA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A6F0C802690; Mon, 29 Mar 2021 15:02:17 +0000 (UTC) Received: from carbon (unknown [10.36.110.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44AAC5D6A1; Mon, 29 Mar 2021 15:02:10 +0000 (UTC) Date: Mon, 29 Mar 2021 17:02:09 +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 1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model Message-ID: <20210329170209.6db77c3d@carbon> In-Reply-To: <20210329080039.32753-1-boon.leong.ong@intel.com> References: <20210329080039.32753-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.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > 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