From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lLyMk-00HB95-8Z for linux-um@lists.infradead.org; Tue, 16 Mar 2021 01:19:24 +0000 Received: by mail-pj1-x102a.google.com with SMTP id j6-20020a17090adc86b02900cbfe6f2c96so548507pjv.1 for ; Mon, 15 Mar 2021 18:19:22 -0700 (PDT) Date: Tue, 16 Mar 2021 10:19:19 +0900 Message-ID: From: Hajime Tazaki Subject: Re: [RFC v8 12/20] um: lkl: initialization and cleanup In-Reply-To: References: <031847ceca73023566fba8e84433a615eac6a2f3.1611103406.git.thehajime@gmail.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-um" Errors-To: linux-um-bounces+geert=linux-m68k.org@lists.infradead.org To: johannes@sipsolutions.net Cc: linux-um@lists.infradead.org, jdike@addtoit.com, richard@nod.at, anton.ivanov@cambridgegreys.com, tavi.purdila@gmail.com, linux-kernel-library@freelists.org, linux-arch@vger.kernel.org, retrage01@gmail.com On Mon, 15 Mar 2021 05:40:39 +0900, Johannes Berg wrote: > > On Wed, 2021-01-20 at 11:27 +0900, Hajime Tazaki wrote: > > > > + panic_blink = lkl_panic_blink; > > Using a panic notifier would seem more appropriate? I understand; will investigate if we can change. > > + init_sem = lkl_sem_alloc(0); > > what's the deal with this? > > > + if (!init_sem) > > + return -ENOMEM; > > + > > + ret = lkl_cpu_init(); > > + if (ret) > > + goto out_free_init_sem; > > + > > + ret = lkl_thread_create(lkl_run_kernel, NULL); > > + if (!ret) { > > + ret = -ENOMEM; > > + goto out_free_init_sem; > > + } > > + > > + lkl_sem_down(init_sem); > > + lkl_sem_free(init_sem); > > You free it before the kernel really even started? The semaphore (init_sem) is unlocked at lkl_run_init(), so this waits for finishing the init call. After the initialization ends, it's safe to free as it's no longer used. I may add some description here to make it clear. -- Hajime _______________________________________________ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um