Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp777204rwe; Fri, 26 Aug 2022 14:26:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR4TtQk6djY0aA2HCSAzzoaTJJXVyd3KEHULE27QVCGXTCKtypc2bSaWgR1FL7VrdW65Ab3H X-Received: by 2002:a63:7d11:0:b0:42b:6394:233 with SMTP id y17-20020a637d11000000b0042b63940233mr4672877pgc.551.1661549195390; Fri, 26 Aug 2022 14:26:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661549195; cv=none; d=google.com; s=arc-20160816; b=fPfduhd0o63nYfyjXpH8c8o0WB986F+rCMMLNd1jz4xaWsJWocK9CG1/FZGbosP8oh 6Pahbnskryj4N9eZHq1A0Uyll88D9nbKkTH0ltnRLVyPrCIJILnjxFIsH15fWofCt11w UhyL4M85qeaABIWtqlaZndnnXkCKhkqkfGOQYfTBOkkOpfFDvant0pSPJRS74rybcrLN I39S3tgbSmVEl2eL+xXrk0jweG/C6F/oYaVEkRmNU9M6QAJXqXJM4V4J2nUaISlEuZ0U 739pGqy0ONKNSERv55Zml4rMprGwwF6eM83upj09oBotWsqQ5EKKEvAOoNM56aR9jIrr yz6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/FKV8NfeABOB5rtbgWYmbTPwp8Mt3Wy5s1mzFHehzCI=; b=KCc/vBDRVhSZZV2NMMLbspXE6sv62/8x91EyAcVc8fGLEEK+yLlEJNOmXBitVw+3wp 3ME0PlXExMIJdUdQHvUZkCuQplSsuZ+b8R6VBs11FgvhiFFcJ1UzjaOJSrEoCbFAQZO0 jZ/Ypc2BW5BlVhGC0cDiLRkhDK3IpkcrEHusM5VFhdRh8Tl1Gx3TMHkQRgPD8no05RR8 kaUkF3VpzRM/XxMh5nvvTuo6788ymaubSRNJcSDaaR3D4txj0RYdHLLDmjwuypTnoVv1 CEx4xrctGqO4KMEwivkjt9+fjJTxQPIkHDe2sFuaUjwiaeSGQO4xfklYUueD07eQAF9j 8EBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=iGdU9mei; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 83-20020a630256000000b004293d32dcb6si2481567pgc.738.2022.08.26.14.26.24; Fri, 26 Aug 2022 14:26:35 -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; dkim=pass header.i=@google.com header.s=20210112 header.b=iGdU9mei; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344317AbiHZUwa (ORCPT + 99 others); Fri, 26 Aug 2022 16:52:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344539AbiHZUw0 (ORCPT ); Fri, 26 Aug 2022 16:52:26 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A7E0DD746 for ; Fri, 26 Aug 2022 13:52:22 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id v16so387536wrm.8 for ; Fri, 26 Aug 2022 13:52:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=/FKV8NfeABOB5rtbgWYmbTPwp8Mt3Wy5s1mzFHehzCI=; b=iGdU9mei9DSZLuS7uHMIilQd2lkoyJdSwxMI0mReZhtN5gkUjZ/wrXKT6lcyVWfI9/ tSFEDjKo7eNzCSM30CeVaMzrZNaxDUnrPRphbe/K9PkwnBBazL4zX7PI3/+oGgwh5Q7L 3AKr1t8J/rXzDnfuOfT7+4CTJJ1LAPtw04XEl6tR5l3+D4KBpg52ot7ATUaTg8NZUb3k or4JQYq+nMk1Gs+Q2/BmuTpabwasj/n4rO+JuYwI5336KrkHtYygVkgHP5DTbK8WQ4/N d1tPQHY3ycYE50AtVpwKar6L2Df6EgDYGz2wDtXA7euueSCPx5CC1D0PpALlrwPPqOhh ysmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=/FKV8NfeABOB5rtbgWYmbTPwp8Mt3Wy5s1mzFHehzCI=; b=Ki6tWrEqSh4dL2U8dt7u9Zuwux5IKy2+G5I9WjvZzG5iJuyypMFgGOOb5vQoO896yj WT1nMYe5H3joX+iEeamISsEU7WibhMpFZs4fhLp6H7dDeLZ9gaIqxlLoXPRmRw9VVL1d il/hJScZQ5x2LfyOSgqhJpJfL1nej2vlCUyrs/yuCAe4oUQlzsvEIA6YU+TRN48UmJdf +iDtRbZC+VLNANoTyY5Lw6vOTBwMIRXvnSVuTtUpnNxRB6mJb7sSRkXWsJO/5EJxxItm wbmDk2vekwiNOS2/NDe5DZET1JcmTAjv9z/Y0BEBYmspENBlF8NC+Etu7rzbLtCVnSKa 41Zg== X-Gm-Message-State: ACgBeo2r8xwdPuOJhLhmhUIWSYyu3QG9D9zILI3pqZ7ErPaXltDvs3N+ WHV/Uz7kKIeKwj6r5ZJgYeAbyvaMlTX3XgaDdt5oBg== X-Received: by 2002:a05:6000:1ac9:b0:220:7f40:49e3 with SMTP id i9-20020a0560001ac900b002207f4049e3mr738777wry.40.1661547139826; Fri, 26 Aug 2022 13:52:19 -0700 (PDT) MIME-Version: 1.0 References: <20220824153901.488576-1-irogers@google.com> <20220824153901.488576-10-irogers@google.com> <2cf6edac-6e41-b43c-2bc1-f49cb739201a@intel.com> <43540a3d-e64e-ec08-e12e-aebb236a2efe@intel.com> In-Reply-To: From: Ian Rogers Date: Fri, 26 Aug 2022 13:52:07 -0700 Message-ID: Subject: Re: [PATCH v3 09/18] perf ui: Update use of pthread mutex To: Namhyung Kim Cc: Adrian Hunter , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Thomas Gleixner , Darren Hart , Davidlohr Bueso , =?UTF-8?Q?Andr=C3=A9_Almeida?= , Nathan Chancellor , Nick Desaulniers , Tom Rix , Weiguo Li , Athira Rajeev , Thomas Richter , Ravi Bangoria , Dario Petrillo , Hewenliang , yaowenbin , Wenyu Liu , Song Liu , Andrii Nakryiko , Dave Marchevsky , Leo Yan , Kim Phillips , Pavithra Gurushankar , Alexandre Truong , Quentin Monnet , William Cohen , Andres Freund , =?UTF-8?Q?Martin_Li=C5=A1ka?= , Colin Ian King , James Clark , Fangrui Song , Stephane Eranian , Kajol Jain , Alexey Bayduraev , Riccardo Mancini , Andi Kleen , Masami Hiramatsu , Zechuan Chen , Jason Wang , Christophe JAILLET , Remi Bernon , linux-kernel , linux-perf-users , bpf , llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Fri, Aug 26, 2022 at 1:40 PM Namhyung Kim wrote: > > On Fri, Aug 26, 2022 at 12:21 PM Adrian Hunter wrote: > > > > On 26/08/22 22:00, Namhyung Kim wrote: > > > On Fri, Aug 26, 2022 at 11:53 AM Adrian Hunter wrote: > > >> Below seems adequate for now, at least logically, but maybe it > > >> would confuse clang thread-safety analysis? > > > > > > I think it's not just about locks, the exit_browser should bail out early > > > if the setup code was not called. > > > > In those cases, use_browser is 0 or -1 unless someone has inserted > > an invalid perf config like "tui.script=on" or "gtk.script=on". > > So currently, in cases where exit_browser() is called without > > setup_browser(), it does nothing. Which means it is only the > > unconditional mutex_destroy() that needs to be conditional. > > Yeah there's a possibility that it can be called with > 0 use_browser > on some broken config or something. So I think it's safer and better > for future changes. I'd thought about a: static bool ui__lock_initialized; but the issue is shouldn't it be atomic? Maybe we should guard it with a lock? Then we are back where we started. Having a clean init/exit invariant would be best but such a change has the potential to be large and out of scope here. Thanks, Ian > Thanks, > Namhyung