linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@kernel.org>, Yang Jihong <yangjihong1@huawei.com>
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
Date: Mon, 24 Oct 2022 08:50:21 -0300	[thread overview]
Message-ID: <Y1Z7/U0ld3QBSHol@kernel.org> (raw)
In-Reply-To: <Y1Z7JB/4t8sEJkV/@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 <yangjihong1@huawei.com>
> > ---
> >  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

  reply	other threads:[~2022-10-24 12:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-22  9:27 [PATCH 0/3] perf daemon/config: Fix a few minor issues Yang Jihong
2022-10-22  9:27 ` [PATCH 1/3] perf daemon: Check err before calling setup_server_config in __cmd_start Yang Jihong
2022-10-24 11:46   ` Arnaldo Carvalho de Melo
2022-10-24 11:50     ` Arnaldo Carvalho de Melo [this message]
2022-10-22  9:27 ` [PATCH 2/3] perf daemon: Complete supported subcommand in help message Yang Jihong
2022-10-22  9:27 ` [PATCH 3/3] perf config: Add missing newline on pr_warning call in home_perfconfig Yang Jihong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y1Z7/U0ld3QBSHol@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=yangjihong1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).