Received: by 2002:a05:7412:3210:b0:e2:908c:2ebd with SMTP id eu16csp774130rdb; Fri, 1 Sep 2023 04:02:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPJEtHR5cvJMg1wYXfRjP4xrMe7CoxxND5+mDoLHJ9W8k9vkS4FPfZmSKtFC53HJ7Ee/dL X-Received: by 2002:a05:6a20:99:b0:14b:9a75:3a5f with SMTP id 25-20020a056a20009900b0014b9a753a5fmr1975501pzg.53.1693566152815; Fri, 01 Sep 2023 04:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693566152; cv=none; d=google.com; s=arc-20160816; b=tdu48MfWgD6Hu1IuqKQKh8W6iL+q716GfR7FYYeqFEZNlg70/gQqVOfPVzYEcIEHKF YbsYMR7w0vylNcDj1KfEPYQRwqUthmh3YNF01UQa0YyF4m8Y5rzegbdJN++BwD0+GudE jnh7zfLjLctkLSGOXDcVi4+uI4JvGr4AV/uvuiIQ3311NIJgyzMO+ojM5qsGfy3eruuR lw3NIkE3X5Zm7BGFVes+wQRwbTiC3mlkq2hD5S2flzT/9mu59ccorPvIWU7Vm92p0uYm SEN2ZYUgUmXpu5etHay9bN/XLXJyXTYjYr6xluRk7rSngcp0QDsTcSDlFUw8h2gE5P9x sq4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=c/Vca4rkHrUEcK737S78s277SvkTmuZV1oh5QPTR0u0=; fh=uZ5Yhq7lIVDz53LKeMdmjxVxRNF2xZI1BfLPMSFxvmk=; b=08ouX5GOZRzYGjs5WbDHk8A/msFrndWEPQ8JNj+Tm7/tsQqqNV5QIkkT5Oc3C6R3Ld tTNJ/F6So8mS5/w8T2UanLt7AYIxQCsUdWoUAVThglxoEixIvDDNMbyUy9wO06y51zR/ SlPJ6FVmTNlg2se16ykz13bjV4h8VxnJPMDVG7xZ4oIavRJAIM1YpwycHbHLXMn8W+aQ +NU1GH3HFtTGiiGrT0fWZVp4bGgzwUBPPu1R1gvSJImfaSbB0uXcZkVKgIaRYL5U2cJU PQWKj+Aj3K3/dFAcyJI9/q3ewVUU6plQ/cSBR9wUYx7NyLaQuMHNqzZQJJ2r1+c+DOlE DxpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cp6-20020a056a00348600b00682babd7453si2704046pfb.142.2023.09.01.04.02.28; Fri, 01 Sep 2023 04:02:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343502AbjHaNvZ (ORCPT + 29 others); Thu, 31 Aug 2023 09:51:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233346AbjHaNvY (ORCPT ); Thu, 31 Aug 2023 09:51:24 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B65F6E47; Thu, 31 Aug 2023 06:51:20 -0700 (PDT) Received: from dggpeml500012.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Rc2b56rjKzrSXw; Thu, 31 Aug 2023 21:49:37 +0800 (CST) Received: from [10.67.110.218] (10.67.110.218) by dggpeml500012.china.huawei.com (7.185.36.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 31 Aug 2023 21:51:18 +0800 Message-ID: <26f8fb43-6ea8-edc2-381d-3600fce261af@huawei.com> Date: Thu, 31 Aug 2023 21:51:18 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH] tracing: zero the pipe cpumask on alloc to avoid spurious -EBUSY Content-Language: en-US To: Brian Foster , CC: , References: <20230831125500.986862-1-bfoster@redhat.com> From: Zheng Yejian In-Reply-To: <20230831125500.986862-1-bfoster@redhat.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.110.218] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500012.china.huawei.com (7.185.36.15) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/8/31 20:55, Brian Foster wrote: > The pipe cpumask used to serialize opens between the main and percpu > trace pipes is not zeroed or initialized. This can result in > spurious -EBUSY returns if underlying memory is not fully zeroed. > This has been observed by immediate failure to read the main > trace_pipe file on an otherwise newly booted and idle system: > > # cat /sys/kernel/debug/tracing/trace_pipe > cat: /sys/kernel/debug/tracing/trace_pipe: Device or resource busy > > Zero the allocation of pipe_cpumask to avoid the problem. > > Fixes: c2489bb7e6be ("tracing: Introduce pipe_cpumask to avoid race on trace_pipes") > Signed-off-by: Brian Foster > --- > > Hi, > > I ran into this problem just recently on one of my test VMs immediately > after updating to a v6.5 base. A revert of the aforementioned commit > addressed the problem. I'm not terribly familiar with the tracing code, > but on further inspection I noticed the cpumask doesn't appear to be > initialized anywhere. I suppose this could alternatively do a > cpumask_clear() or whatever after allocation, but either way this > addresses the problem for me. Yes, pipe_cpumask must be initialized. -- Thanks, Zheng Yejian > > Please CC on replies as I'm not subscribed to the list. Thanks. > > Brian > > kernel/trace/trace.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > index 8e64aaad5361..2656ca3b9b39 100644 > --- a/kernel/trace/trace.c > +++ b/kernel/trace/trace.c > @@ -9486,7 +9486,7 @@ static struct trace_array *trace_array_create(const char *name) > if (!alloc_cpumask_var(&tr->tracing_cpumask, GFP_KERNEL)) > goto out_free_tr; > > - if (!alloc_cpumask_var(&tr->pipe_cpumask, GFP_KERNEL)) > + if (!zalloc_cpumask_var(&tr->pipe_cpumask, GFP_KERNEL)) > goto out_free_tr; > > tr->trace_flags = global_trace.trace_flags & ~ZEROED_TRACE_FLAGS; > @@ -10431,7 +10431,7 @@ __init static int tracer_alloc_buffers(void) > if (trace_create_savedcmd() < 0) > goto out_free_temp_buffer; > > - if (!alloc_cpumask_var(&global_trace.pipe_cpumask, GFP_KERNEL)) > + if (!zalloc_cpumask_var(&global_trace.pipe_cpumask, GFP_KERNEL)) > goto out_free_savedcmd; > > /* TODO: make the number of buffers hot pluggable with CPUS */