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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C34AFECAAD2 for ; Sat, 27 Aug 2022 07:11:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236442AbiH0HLh (ORCPT ); Sat, 27 Aug 2022 03:11:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233391AbiH0HLg (ORCPT ); Sat, 27 Aug 2022 03:11:36 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B7DFB9403; Sat, 27 Aug 2022 00:11:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661584295; x=1693120295; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=5//vesnR6q4a/EAJehddmLIvKMXBYIPt2MNCh84f7z8=; b=HDGGL2FSw2Z0BqVL3O0LKqQY8SzAMplJSwPbGFk+YQX+txVqwGad30PR V+/bHgeHK3JYGP3pG5/ZuzL3kJyVrKY4xdXO1TU8pvG1pyz1RcRrlgxX9 VarGk0DzuY6wypE3j8ibXEA8sku6AwV79A8EI42VM7xakKevLN9e45fx8 baIbola4VjhCoQ8Q+lRocAsxseCenHK9ie+/4WeckpvuJmalqs0ARDVyI 7WJw7eq3SUdBOREF9lLJoCp/KL3e4HZG2PwrDrUbX4lvB4rUs62acsw1J uE4VSNtyDjFpyA1NzoCOY1ep6uGUl3xD8+a5Liin46C0YIZ5R2WGcnrf4 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="295418832" X-IronPort-AV: E=Sophos;i="5.93,267,1654585200"; d="scan'208";a="295418832" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Aug 2022 00:11:35 -0700 X-IronPort-AV: E=Sophos;i="5.93,267,1654585200"; d="scan'208";a="671747248" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.252.52.233]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Aug 2022 00:11:23 -0700 Message-ID: Date: Sat, 27 Aug 2022 10:11:19 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.11.0 Subject: Re: [PATCH v3 09/18] perf ui: Update use of pthread mutex Content-Language: en-US To: Ian Rogers , Namhyung Kim Cc: 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 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> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 26/08/22 23:52, Ian Rogers wrote: > 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? No, it is only accessed from the main thread.