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 X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=BAYES_00,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E679DC433E0 for ; Sun, 7 Feb 2021 01:39:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A571D64E8B for ; Sun, 7 Feb 2021 01:39:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbhBGBj1 (ORCPT ); Sat, 6 Feb 2021 20:39:27 -0500 Received: from mail-lj1-f176.google.com ([209.85.208.176]:33014 "EHLO mail-lj1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhBGBjY (ORCPT ); Sat, 6 Feb 2021 20:39:24 -0500 Received: by mail-lj1-f176.google.com with SMTP id a25so12437686ljn.0 for ; Sat, 06 Feb 2021 17:39:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mL9d9Wqg5g+wwMLVDrn7VkCf+Ey0d26fPVchp2XF76c=; b=CA7ELk+kIOZ7RqkdW4D5mjF2YxZCPmFIO3t4T2JPddqky0onDvtdX1dVtp/hHb479H bDdGNGsArJ7Lfaujh1VeDfNs88aYSKC2Iw2+pQK9omU55mTMIpjPyW91lC0YWNPmP3Kc Zkxz+DtqoDyR/aDcN5JPQVzROEMmElA/nE8iwSCxqfP74F8rX2rENqWgVRqXxeNDDJAt Sv51BA78feY4TZ4UDaGUgkBXWVHcWsKZI0338BDkcvAZF+xBLJ3ZQCEqVfFMdb/2d0oo r8CNAictjpd4oMPhylBXwHBlsyjrZIiTAnsc/X7XFGtNFhDdls8iQdXyrWAO9dDMTbJR GiAA== X-Gm-Message-State: AOAM5319SrlWgp7zWvpRCUOt+eG9djmJwDR4DrBDaVxwZ+g4qJ6XqYTB U8oknjSO++HyxqTz+5txp8l8o6DGc1lk/7C5bA4= X-Google-Smtp-Source: ABdhPJwRVj0u1xMmtaHeYD712f2jabL47pF6ImI11krM4G/acsBk+vTIHW7zXEMsII85qzCGAcI7J3KeZRTDLsh5bh0= X-Received: by 2002:a2e:9949:: with SMTP id r9mr6359921ljj.393.1612661922481; Sat, 06 Feb 2021 17:38:42 -0800 (PST) MIME-Version: 1.0 References: <20210129134855.195810-1-jolsa@redhat.com> <20210130234856.271282-1-jolsa@kernel.org> <20210130234856.271282-7-jolsa@kernel.org> In-Reply-To: From: Namhyung Kim Date: Sun, 7 Feb 2021 10:38:31 +0900 Message-ID: Subject: Re: [PATCH 06/24] perf daemon: Add config file support To: Jiri Olsa Cc: Jiri Olsa , Arnaldo Carvalho de Melo , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Michael Petlan , Ian Rogers , Stephane Eranian , Alexei Budankov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 7, 2021 at 7:35 AM Jiri Olsa wrote: > > On Sat, Feb 06, 2021 at 05:05:04PM +0900, Namhyung Kim wrote: > > On Fri, Feb 5, 2021 at 9:56 PM Jiri Olsa wrote: > > > > > > On Fri, Feb 05, 2021 at 09:14:54PM +0900, Namhyung Kim wrote: > > > > On Sun, Jan 31, 2021 at 8:49 AM Jiri Olsa wrote: > > > > [SNIP] > > > > > @@ -263,9 +605,16 @@ static int __cmd_start(struct daemon *daemon, struct option parent_options[], > > > > > signal(SIGTERM, sig_handler); > > > > > > > > > > while (!done && !err) { > > > > > - if (fdarray__poll(&fda, -1)) { > > > > > + err = daemon__reconfig(daemon); > > > > > > > > I think it's confusing since you put the reconfig function here. > > > > What not split normal and reconfig passes? > > > > > > hum, not sure what's confusing in here? I've been known to > > > produce confusing code, but this one seems clear to me > > > > Maybe it's because of the name. I thought reconfig is a > > special case when it detects some change. But you call > > it in the loop unconditionally. > > > > > > > > > > > > > I mean something like below > > > > > > > > __cmd_start() > > > > { > > > > setup_server_config(); > > > > daemon__run(); > > > > > > what's daemon__run? the daemon operates in the while loop below > > > > I thought about starting the sessions in the config. > > > > > > > > > > > > > while (!done && !err) { > > > > ... > > > > if (reconfig) { > > > > daemon__kill(); > > > > > > you don't kill daemon for each reconfig change, > > > we detect changed sessions and kill/restart only them > > > > Yep, we can make it that way. > > > > > > > > > setup_server_config(); > > > > daemon__reconfig(); > > > > } > > > > } > > > > > > > > > so basically the current workflow is: > > > > > > setup_server_config <--- reads config file, prepares session objects > > > > > > while (!done) { > > > daemon__reconfig <--- check session objects states and run/stop them > > > > Hmm.. then how about rename it to daemon__handle_state() > > or daemon__do_loop() or something? > > well it handles reconfig, so I don't think that there's > better name than daemon__reconfig ;-) > > apart from handle_server_socket, all the other functions > we call after poll can change session state, so we need > to 'reconfig' sessions each time we do a loop OK then. Thanks for the explanation! Thanks, Namhyung