Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6741696rwi; Mon, 24 Oct 2022 05:39:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7STjsipgTelsu1U/ZH/BwdGHIE1g97ngbqRFppgaX9b5p66H/6UtyGhkvgB+t1eFZXAnp/ X-Received: by 2002:a17:907:2712:b0:78d:a223:729b with SMTP id w18-20020a170907271200b0078da223729bmr27718527ejk.443.1666615174702; Mon, 24 Oct 2022 05:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615174; cv=none; d=google.com; s=arc-20160816; b=uTDJL/zM05B4OIlwVOlTHzYy6pGl93vu12uPzpHDI7tEnyifb/ld8aWuUS5FsQ2YpZ s2vJkNX87DB3Buacsb48sOsPmCNoMzr3CXtzX5gVknXh5nKXQVQXfFBAYAwNHm1zwRI6 g6nXgk+QPnmhOe/i1x8S+7KGAc1I4PqhJReqSWhorhjByThTPtvi6SkI5xDVIeffdMcq BOhSw8Olx4pVH9K4uC5asquMb6ueELsRLaOLhgEMeJj1fgbFeOnQ0ujds04WyB5RLUf0 JZ2i7u/+nuhv+ZiyD0UESpFEGhpNShfyKU6EAwUnKlh1o3yvR1bIuI9bBi8r+feCG5zI QAxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xp6XajTMhtM/cry2As12R1eCI4ZnfYLkHjElLieiRGM=; b=H/Kl5nwQwyBYzoL1Tq9JxELJDYR+jVzP58lpGxRuL1R0ok/S3wdxPyzuRGPHUrSlnw oTJae0Onz+yzlNvsXlr+GdnKAI4MBm3Y0+d9CHjZLwvhlVprviw24lRowqJFwJwI4rJx XoqCfofKHGShcRPkfXh/gONHYFKA1W3BBaBvwVxIjViKKbhHEW2DOqKy75TOZgAlzRIy XorHG7VPk4ZGU36xKeTHlCgH1IXTKRdNJQsu1H7/Drp52kWl100KoaLcy7ySARooZwiH kkpGEyyvZzrnVIWlnwfD8RMPDiAs6p9eFU89vFub/VIMIwi+psx8vWBOl3pXuxfbOWzC lVIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lboxBCI1; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o19-20020a170906975300b00787b0b0a96esi22056643ejy.131.2022.10.24.05.39.10; Mon, 24 Oct 2022 05:39:34 -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=@kernel.org header.s=k20201202 header.b=lboxBCI1; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbiJXMHi (ORCPT + 99 others); Mon, 24 Oct 2022 08:07:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233064AbiJXMFC (ORCPT ); Mon, 24 Oct 2022 08:05:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81ED87D7B3; Mon, 24 Oct 2022 04:51:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3B2FEB811A6; Mon, 24 Oct 2022 11:50:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B172EC433C1; Mon, 24 Oct 2022 11:50:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666612224; bh=G+CUiQUJ1bZrDrtFfptsL95qRNAeWuDsQo98fY38vHc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lboxBCI1uZp7dqHyNgbq/Tsb1EzRMKiAXaoJGxoX2Lic709NQpDfLIIp2TTHsJY5o K1LK82nj9+J/j46Zb7zYIqy6uNToxFlPMa+zv5z6Oy8K2CzM3caJhCuaSmJYIjESns TdzHLr2SKKWLmzXjAOzxKc44f0VgWVixqbA1Vdz7/zyhq0j5ICE0Jq5VIsEJ5oOua0 tuyV0w9Km5yYLSK0UpDLSwtHgKQK4PJ/pOYv2sPnOhN3SRsEI1YHxMXNE0Le2ij89L YO6d0a4vhFIfIRNzKq+8TDuEdI4PhlMJSNX218lx4lJkg5YtTchd8MWN9YSoFyPLD9 0cBD0wixZYJgA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id B966A404BE; Mon, 24 Oct 2022 08:50:21 -0300 (-03) Date: Mon, 24 Oct 2022 08:50:21 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa , Yang Jihong Cc: peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org, adrian.hunter@intel.com, ak@linux.intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] perf daemon: Check err before calling setup_server_config in __cmd_start Message-ID: References: <20221022092735.114967-1-yangjihong1@huawei.com> <20221022092735.114967-2-yangjihong1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Em Mon, Oct 24, 2022 at 08:46:44AM -0300, Arnaldo Carvalho de Melo escreveu: > Em Sat, Oct 22, 2022 at 05:27:33PM +0800, Yang Jihong escreveu: > > If err!=0 before calling setup_server_config and reconfig==true, > > setup_server_config function may return 0 and err becomes 0. > > As a result, previous error is overwritten, need to check value of err first. Applied patches 2 and 3 meanwhile, thanks. - Arnaldo > > Signed-off-by: Yang Jihong > > --- > > tools/perf/builtin-daemon.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c > > index 6cb3f6cc36d0..b82bd902602a 100644 > > --- a/tools/perf/builtin-daemon.c > > +++ b/tools/perf/builtin-daemon.c > > @@ -1333,7 +1333,7 @@ static int __cmd_start(struct daemon *daemon, struct option parent_options[], > > if (fda.entries[signal_pos].revents & POLLIN) > > err = handle_signalfd(daemon) < 0; > > > > - if (reconfig) > > + if (!err && reconfig) > > err = setup_server_config(daemon); > > } > > Expanding the context a bit: > > while (!done && !err) { > err = daemon__reconfig(daemon); > > if (!err && fdarray__poll(&fda, -1)) { > bool reconfig = false; > > if (fda.entries[sock_pos].revents & POLLIN) > err = handle_server_socket(daemon, sock_fd); > if (fda.entries[file_pos].revents & POLLIN) > err = handle_config_changes(daemon, conf_fd, &reconfig); > if (fda.entries[signal_pos].revents & POLLIN) > err = handle_signalfd(daemon) < 0; > > if (!err && reconfig) > err = setup_server_config(daemon); > } > } > > The err you're checking may be the last one, that may have overwritten > 'err' from handle_config_changes(), perhaps moving things around helps? > I.e.: > if (!err && fdarray__poll(&fda, -1)) { > bool reconfig = false; > > if (fda.entries[sock_pos].revents & POLLIN) > err = handle_server_socket(daemon, sock_fd); > if (fda.entries[signal_pos].revents & POLLIN) > err = handle_signalfd(daemon) < 0; > if (fda.entries[file_pos].revents & POLLIN) > err = handle_config_changes(daemon, conf_fd, &reconfig); > > if (!err && reconfig) > err = setup_server_config(daemon); > } > > > ? > > Jiri? > > - Arnaldo > > > } > > -- > > 2.30.GIT > > -- > > - Arnaldo -- - Arnaldo