From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 9DAA43250 for ; Mon, 15 Jan 2018 22:45:56 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jan 2018 13:45:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,365,1511856000"; d="scan'208";a="195835927" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by fmsmga006.fm.intel.com with ESMTP; 15 Jan 2018 13:45:54 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.236]) by IRSMSX102.ger.corp.intel.com ([169.254.2.180]) with mapi id 14.03.0319.002; Mon, 15 Jan 2018 21:45:54 +0000 From: "Ananyev, Konstantin" To: "Tan, Jianfeng" , "dev@dpdk.org" CC: "Burakov, Anatoly" , "Richardson, Bruce" , "thomas@monjalon.net" Thread-Topic: [PATCH v2 2/4] eal: add and del secondary processes in the primary Thread-Index: AQHTipGFxTbmQT/O8EmqOKrcOyToFKN1fYZg Date: Mon, 15 Jan 2018 21:45:53 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772588627DE94@irsmsx105.ger.corp.intel.com> References: <1512067450-59203-1-git-send-email-jianfeng.tan@intel.com> <1515643654-129489-1-git-send-email-jianfeng.tan@intel.com> <1515643654-129489-3-git-send-email-jianfeng.tan@intel.com> In-Reply-To: <1515643654-129489-3-git-send-email-jianfeng.tan@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzFmN2UzZjktYzMxZC00MTE2LTkxMGItOTMzMjI2OWRmOWMyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6ImFIT2JlTzFTRjdaUXM1UDhpOXJJS1dqVVBkQU80S2tHQlVRZFRuUEF6NzQ9In0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 2/4] eal: add and del secondary processes in the primary X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jan 2018 21:45:57 -0000 > -----Original Message----- > From: Tan, Jianfeng > Sent: Thursday, January 11, 2018 4:08 AM > To: dev@dpdk.org > Cc: Burakov, Anatoly ; Richardson, Bruce ; Ananyev, Konstantin > ; thomas@monjalon.net; Tan, Jianfeng > Subject: [PATCH v2 2/4] eal: add and del secondary processes in the prima= ry >=20 > By the multi-process channel, we add an mp action named "proc". >=20 > As a secondary process starts, it sends a "proc add" message to > the primary. >=20 > As the primary finds a failure in sending message to a specific > secondary process, that secondary process is treated as exited; > and we remove it from the secondary array by sending a "proc del" > message to the primary itself. >=20 > Test: > 1. Start the primary and the secondary process > $ (testpmd) -c 0x3 -n 4 -- -i > $ (helloworld) -c 0xc -n 4 --proc-type=3Dauto -- >=20 > 2. Check the log of testpmd: > ... > EAL: bind to /var/run/.rte_unix > ... > EAL: add secondary: /var/run/.testpmd_unix_(xxx) > ... >=20 > 3. Check the log of helloworld: > ... > EAL: bind to /var/run/.testpmd_unix_xxx > EAL: bind to /var/run/.testpmd_unix_c_xxx > ... >=20 > Signed-off-by: Jianfeng Tan > --- > lib/librte_eal/common/eal_common_proc.c | 88 +++++++++++++++++++++++++++= +++++- > 1 file changed, 86 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/com= mon/eal_common_proc.c > index d700e9e..70519cc 100644 > --- a/lib/librte_eal/common/eal_common_proc.c > +++ b/lib/librte_eal/common/eal_common_proc.c > @@ -54,6 +54,13 @@ struct mp_msghdr { > char params[0]; > } __rte_packed; >=20 > +struct proc_request { > +#define MP_PROC_ADD 0 > +#define MP_PROC_DEL 1 > + int type; > + char path[MAX_UNIX_PATH_LEN]; > +}; > + > int > rte_eal_primary_proc_alive(const char *config_file_path) > { > @@ -214,6 +221,58 @@ mp_handle(void *arg __rte_unused) > return NULL; > } >=20 > +static int > +add_sec_proc(const char *path) > +{ > + int i; > + > + for (i =3D 0; i < MAX_SECONDARY_PROCS; ++i) > + if (mp_sec_sockets[i] =3D=3D NULL) > + break; > + if (i < MAX_SECONDARY_PROCS) > + mp_sec_sockets[i] =3D strdup(path); > + > + return i < MAX_SECONDARY_PROCS; > +} > + > +static int > +del_sec_proc(const char *path) > +{ > + int i; > + > + for (i =3D 0; i < MAX_SECONDARY_PROCS; ++i) { > + if (!strcmp(mp_sec_sockets[i], path)) { > + free(mp_sec_sockets[i]); > + mp_sec_sockets[i] =3D NULL; > + break; > + } > + } > + > + return i < MAX_SECONDARY_PROCS; > +} I am not sure we really need all these add/del messages and mp_sec_sockets[= ]... For broadcast - why we can't just scan contents of our home dir for all ope= n client sockets and send a message to each such socket found. Konstantin > + > +static int > +mp_primary_proc(const void *params, > + int len __rte_unused, > + int fds[] __rte_unused, > + int fds_num __rte_unused) > +{ > + const struct proc_request *r =3D (const struct proc_request *)params; > + > + switch (r->type) { > + case MP_PROC_ADD: > + RTE_LOG(INFO, EAL, "add secondary: %s\n", r->path); > + return add_sec_proc(r->path); > + case MP_PROC_DEL: > + RTE_LOG(INFO, EAL, "del secondary: %s\n", r->path); > + return del_sec_proc(r->path); > + default: > + RTE_LOG(ERR, EAL, "invalid type: %d\n", r->type); > + } > + > + return -1; > +} > + > static inline const char * > get_unix_path(int is_server) > { > @@ -267,6 +326,22 @@ rte_eal_mp_channel_init(void) > if (mp_fd < 0) > return -1; >=20 > + if (rte_eal_process_type() =3D=3D RTE_PROC_PRIMARY) { > + if (rte_eal_mp_action_register("proc", mp_primary_proc) < 0) { > + RTE_LOG(ERR, EAL, "failed to register handler\n"); > + goto error; > + } > + } else { > + struct proc_request r; > + > + r.type =3D MP_PROC_ADD; > + snprintf(r.path, MAX_UNIX_PATH_LEN, "%s", get_unix_path(1)); > + if (rte_eal_mp_sendmsg("proc", &r, sizeof(r), NULL, 0) < 0) { > + RTE_LOG(ERR, EAL, "failed to add into primary\n"); > + goto error; > + } > + } > + > if (pthread_create(&tid, NULL, mp_handle, NULL) < 0) { > RTE_LOG(ERR, EAL, "failed to create mp handle thead: %s\n", > strerror(errno)); > @@ -354,10 +429,19 @@ send_msg(int fd, const char *dst_path, struct mp_ms= ghdr *msg, int fds[]) > if (ret < 0) { > RTE_LOG(ERR, EAL, "failed to send msg: %s\n", strerror(errno)); >=20 > - if (rte_eal_process_type() =3D=3D RTE_PROC_PRIMARY) > + if (rte_eal_process_type() =3D=3D RTE_PROC_PRIMARY) { > + struct proc_request r; > + > RTE_LOG(ERR, EAL, "secondary process (%s) exited\n", > dst_path); > - else if (!rte_eal_primary_proc_alive(NULL)) > + r.type =3D MP_PROC_DEL; > + snprintf(r.path, MAX_UNIX_PATH_LEN, "%s", dst_path); > + if (rte_eal_mp_sendmsg("proc", &r, > + sizeof(r), NULL, 0) < 0) > + RTE_LOG(ERR, EAL, > + "failed to del secondary %s\n", > + dst_path); > + } else if (!rte_eal_primary_proc_alive(NULL)) > RTE_LOG(ERR, EAL, "primary process exited\n"); >=20 > return 0; > -- > 2.7.4