Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp181894rdb; Thu, 8 Feb 2024 02:57:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV7SWqZfB1w0JK500rvpy38Lf12dXxyNgLMXzsOZDe1pnvRJGmqT9yJkfP33XkLdV2JOPiOhqnJQT2LwRq2YyxhFglb80vLTaYQXX5YRA== X-Google-Smtp-Source: AGHT+IHRojwwuQ3+VJtwfuqKKUipSV7WfeUZJ1cRPuIjpEMKkfxVLGdrH7WAP1+pkXuRDxQMAiWE X-Received: by 2002:a05:6a21:3283:b0:19e:aa94:4efa with SMTP id yt3-20020a056a21328300b0019eaa944efamr3409922pzb.6.1707389841882; Thu, 08 Feb 2024 02:57:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707389841; cv=pass; d=google.com; s=arc-20160816; b=Q5N7TXiKIyW+n5vhv9a7IT9ddLjOy6YUuvOlMPpKRXuFsqWIh5CATksJIF19YPIcJw jPgvkwQUoNso4sI5SvDxNK3ZvUQ7+si54bhSqRVTCwp90tMVlyudIVOPcS0aJXT3iYcE jXpC2FAoleb6GsQgd23SXQEYXSsgTBRa8Jm9dw1hd+SURsdvQaW0NL+Z+s47gHt1s4n8 QF01o6eJ/MEt3J49VJIGMwTJTNdcZw/mf5W9/Btbft/GAMQiA4OPindbkH2qAktHGF9S EutBvlw5GgFVyFvfncwYL2WFdfGgG/eGJL6NVEgtS93REmyC9SDwTxVqOMMXVkItEydq LD0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=xKeQ9fcUMgud2iiOOvuDdu/2E6NwbXSOAkdeYBuJopc=; fh=wjK6bA/i2bG5a3GIrHH4wPoW92R8ExPsBP+U4SNUJLg=; b=PVkfT/0TaF8F0xnKwgZBk/RYF3cXaVYT663AxeYwUsOhFdshKrzvKFJ/PN+yKzqdbb BilppAhZmlmObgOOTQ73+kyTBNVp6rMvjwiRkwReP+ke8buYmyfDRUiSR0txV53j9ESZ 0JHPGwf0l25+A7Hcuo8CxlvfYXFVfVfsL3y8f+ar0YGRIeWN2QPCx6uwRB5LNvrlm/u2 mrb/lSYLlvhibvAivmRfzSV2Ot50egyKP0i1/azpJTDwhyYcM8Ab2jxmfi2ef9wqUrfG fEIqiUixgQIBGbqEblYkrl4dW3vMBQ9kOgtStttC6XZ7f/WutcK3DeW+UYEbm9SMssAs KzLw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lEtSp19+; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-57855-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57855-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com X-Forwarded-Encrypted: i=2; AJvYcCWzt/YmaRw07brWyrBikbXJHR95spqzBuQ4YR/BhUhZa3TJ5AqCy+ZU8sasOyjtDMi/Viw6bolrjddgRNTGqmo22j4E51yiTjS9e1plIQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q11-20020a17090a9f4b00b00296fba17af7si810792pjv.160.2024.02.08.02.57.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 02:57:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57855-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lEtSp19+; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-57855-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57855-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 49F3EB2CAE3 for ; Thu, 8 Feb 2024 10:26:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 001FE6DCEC; Thu, 8 Feb 2024 10:26:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="lEtSp19+" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D1CC6DCFE; Thu, 8 Feb 2024 10:26:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707387962; cv=none; b=USfXGi2Oi28oV6wNkOfdczBaeVD20r1VqwxtApC5VD3ohcvKscI/Zn3J2yC1NKwfIqSrwSCyIxV9GEUhdg34HxMYMLmZeeS6gnNwnAJgXPXGB3ilZmuO0P5ubhM1GBgjbBGtWS5AdRzUmrWt4n37Hx4L63IUUl4Wn0A/q1G1Grw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707387962; c=relaxed/simple; bh=emnpEIwAYGIHVgid4NR926MQK2rJE8cWMDX2nfQ2l5A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iR7boCyUt53PGZYwf8MIOdMmzNm9Qus/U3ZShTYQo8u8gNZjKRkIKQo1bQKy7yUzOIYx+viFzmU9LnUHrEmCiPyHkpnyQzUvCbfaDsjpEAuajTf5EGRUVGlU9HgGmgjyXiYkoABfxx73zs1egHJuWq239i7IFAzogmh2sMTAjAM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=lEtSp19+; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4189cIFV002468; Thu, 8 Feb 2024 10:25:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=xKeQ9fcUMgud2iiOOvuDdu/2E6NwbXSOAkdeYBuJopc=; b=lEtSp19+zrRLKzGQUc/SipIlMgyHTz/orTtxhwvfTnkCZq2UuKrZ/OBDBE+OHofSMKjl vhwEBWdjArjFk3TVoO042zEgBASib9TCUvuCkLka/C3EKbUjCp4++FnUwgSl59n/UA7G BBp/ccpZXJ+rEGEQg+dyXMyIopeUPfyXDT9RWAif2RdvYBxiv6SHj7rN0qHy8b7HQSIQ 9IqRlAAxmH5Z7iZxp9a74rrRFCu9g+UYB7lsDmVDXhIVunJTBa6fMF1Ccbrdil42TtDo AZHjRA3YZoaOj7VvAHYJiJvlHVpISsXseSKXXOp4NNteFJ8+i3rIiXJgrmYtaLGYbZRd wQ== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w4vg9h24c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Feb 2024 10:25:53 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 4189xAxG005430; Thu, 8 Feb 2024 10:25:53 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3w21akuk8p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Feb 2024 10:25:53 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 418APpbs44499240 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 8 Feb 2024 10:25:51 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 309EA2004B; Thu, 8 Feb 2024 10:25:51 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE67E20040; Thu, 8 Feb 2024 10:25:50 +0000 (GMT) Received: from [9.171.57.15] (unknown [9.171.57.15]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 8 Feb 2024 10:25:50 +0000 (GMT) Message-ID: <8c986cb3-61b3-4f65-81c9-ffcfa994390f@linux.ibm.com> Date: Thu, 8 Feb 2024 11:25:50 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] tracing: use ring_buffer_record_is_set_on() in tracer_tracing_is_on() Content-Language: en-US To: Steven Rostedt , Sven Schnelle Cc: Masami Hiramatsu , Mathieu Desnoyers , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org References: <20240205065340.2848065-1-svens@linux.ibm.com> <20240205075504.1b55f29c@rorschach.local.home> <20240205092353.523cc1ef@rorschach.local.home> <20240206060113.39c0f5bc@rorschach.local.home> <20240207060923.182ecb55@rorschach.local.home> <9a062196-ccbe-440e-a2f9-23eb8c5eb837@linux.ibm.com> <20240207072812.4a29235f@rorschach.local.home> <20240207104703.071ee985@rorschach.local.home> From: Mete Durlu In-Reply-To: <20240207104703.071ee985@rorschach.local.home> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: sxZlMAMX3gmObfvP11ERkPRy8Nj5sqUe X-Proofpoint-GUID: sxZlMAMX3gmObfvP11ERkPRy8Nj5sqUe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_01,2024-02-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 phishscore=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 mlxlogscore=984 suspectscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080054 On 2/7/24 16:47, Steven Rostedt wrote: > On Wed, 07 Feb 2024 14:33:21 +0100 > Sven Schnelle wrote: > >> My assumption without reading the code is that something like this >> happens: >> >> CPU0 CPU1 >> [ringbuffer enabled] >> ring_buffer_write() >> if (atomic_read(&buffer->record_disabled)) >> goto out; >> echo 0 > tracing_on >> record_disabled |= RB_BUFFER_OFF >> csum1=`md5sum trace` > > Note, the CPU1 is performing with preemption disabled, so for this to > happen, something really bad happened on CPU0 to delay preempt disabled > section so long to allow the trace to be read. Perhaps we should have > the return of the echo 0 > tracing_on require a synchronize_rcu() to > make sure all ring buffers see it disabled before it returns. > > But unless your system is doing something really stressed to cause the > preempt disabled section to take so long, I highly doubt this was the > race. > I have been only able to reliably reproduce this issue when the system is under load from stressors. But I am not sure if it can be considered as *really stressed*. system : 8 cpus (4 physical cores) load : stress-ng --fanotify 1 (or --context 2) result : ~5/10 test fails of course as load increases test starts to fail more often, but a single stressor doesn't seem like much to me for a 4 core machine. after adding synchronize_rcu() + patch from Sven, I am no longer seeing failures with the setup above. So it seems like synchronize_rcu() did the trick(or at least it helps a lot) for the case described on the previous mail. I couldn't trigger the failure yet, not even with increased load(but now the test case takes > 5mins to finish :) ). Here is the diff: diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c @@ -9328,10 +9328,12 @@ rb_simple_write(struct file *filp, const char __user *ubuf, val = 0; /* do nothing */ } else if (val) { tracer_tracing_on(tr); + synchronize_rcu(); if (tr->current_trace->start) tr->current_trace->start(tr); } else { tracer_tracing_off(tr); + synchronize_rcu(); if (tr->current_trace->stop) tr->current_trace->stop(tr); Not 100% sure if these were the correct places to add them.