From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBD19C433E1 for ; Mon, 29 Mar 2021 16:26:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2A0861970 for ; Mon, 29 Mar 2021 16:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231649AbhC2QZi (ORCPT ); Mon, 29 Mar 2021 12:25:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36845 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231646AbhC2QZQ (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-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-296-S1ksDskhN9GR9fp4Eh5MCg-1; Mon, 29 Mar 2021 12:25:11 -0400 X-MC-Unique: S1ksDskhN9GR9fp4Eh5MCg-1 Received: by mail-ej1-f72.google.com with SMTP id bg7so6066668ejb.12 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=Anadvr2oJH5d1yJxC/2ZIZhUjK98ravsJfqDixjUiUEY4K9nim0ilz/9b1L3FOrFjS r/6ycQ/tcD1/rLfAZW3sAzADblHr0Ydi1Tx+AbrEJ03aKIhRirsIQNgUSZBQqdhpcQJK zEHPqWDxOyZCIbuKvVZZJ4/3ocCKJKMibCoTamPnvRqX9vHwpg22d629MqGwrTjVaqwU J+mji/uR94NIxuKnsiPBmTkj9Um6+uZl7i33qm/iXZXOPB2966/flR1B6oLi/3xFRDIq +h1i3PyqtvzDwicZq25ToMeeIwVxppDMaD9Ud+yW4wsRveEjwpegO/KmXLcES6pErTFD Ktgg== X-Gm-Message-State: AOAM533ZrtjNpx6xS7kjBrVVdri+/PUo9+wd5ccewNNu9XCFHPHq6ORO Zs/yil9tU9gKa7M0tmPB8L72PG1GX5vfrCmt5e9iA9SgcsIL78CJsJRko/dwYRX4rk2QJFIEE3B E+H5BcCR+ntNfgkhG X-Received: by 2002:a50:ec96:: with SMTP id e22mr29345934edr.385.1617035110008; Mon, 29 Mar 2021 09:25:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywYRxi7n5QniEJaNO6UMg08JtWmwcuPYfyG7Lv1dtxhDjfWqUvGzbcye9KyF5FRMcPYikhkQ== 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: netdev@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