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=-0.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 4E76EC433DB for ; Tue, 16 Mar 2021 01:20:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 229F564F89 for ; Tue, 16 Mar 2021 01:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230484AbhCPBTn (ORCPT ); Mon, 15 Mar 2021 21:19:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231305AbhCPBTV (ORCPT ); Mon, 15 Mar 2021 21:19:21 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81CC3C06174A for ; Mon, 15 Mar 2021 18:19:21 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id nh23-20020a17090b3657b02900c0d5e235a8so567746pjb.0 for ; Mon, 15 Mar 2021 18:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:from:to:cc:subject:in-reply-to:references :user-agent:mime-version; bh=nwqe8UgBhqxk+hw62UxI72OTBYeNX/dwsxv8iPGRl6o=; b=kPDGwaz2b1P+N6X0Tod9g/ZarUaLOygjU7plkYB/Ib19QkamQmumM17hd6TaRQFePk ixjdmO4RMPR37UkeMDTLddxK4qGbZqLMML0ppvc0pagvq7P9qv6r8I1oJ51iik3fYGPI Nz/DQ/WkGaOV3OK8J3MplFeH4bqrqacB3FIwjLMk0HgT6dxdusdCnmumxyHzmQQG3ROw plUFv0f76BrYGM0HLrYevr8qDz5r6KAUBmuPWeRFXbuSTJ8wW4zhdMpjz9FDYm4QcZJQ 6qjMjHVcKrF4QOiFOLEUeiUFOGhRoErx1F05OBcfbRb+Vtfh91aaeqQr8MTszP5a0oN6 Z7WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:from:to:cc:subject:in-reply-to :references:user-agent:mime-version; bh=nwqe8UgBhqxk+hw62UxI72OTBYeNX/dwsxv8iPGRl6o=; b=msijugc94T0LyXoZOmE2GTliDccZsQDydgv8CmvVBADvjhHLaJF9o+YFoMmE9PQx8f wXvW5gBJkfxlihoexBOHwrAMoi9PmWV87INQmnpsYeNkc9WhUEjXWQLhsUkX3g9U8wfO 5UA/xsiaBF+XXnVdSuVEQGNBXCTy3t0sw1gN4nPOvTiLkll4/3O9M+ZsvHLL1pZbh+9F 1NE5CeiyM7nfusEGhIasV86Y03VwmU0BrmUAmrcUPAS6KzOVBPDt1EOHCOctiUqwi0nv 8cvrCTgmhla1RV8QB5ZtAUO9iSWJrskvUCGLhN/mfHAr7KsFJCneb7vEtdC1S/qkZgw1 uWdg== X-Gm-Message-State: AOAM531YuCV4D+U8x44bQt5mJIofTHO70hQjAIjL7fxC01diCOa1au7U Rh/MYd2109KORpItr55O9H0= X-Google-Smtp-Source: ABdhPJzI8T5PSGsw5CBLTjpozOD4z24EgpE5EIVh37XFps8m9YgKA6xmMUCZfDksYIiyFmtKRGxMuQ== X-Received: by 2002:a17:90a:9d82:: with SMTP id k2mr2008631pjp.48.1615857561017; Mon, 15 Mar 2021 18:19:21 -0700 (PDT) Received: from sun.local.gmail.com (219x123x138x129.ap219.ftth.ucom.ne.jp. [219.123.138.129]) by smtp.gmail.com with ESMTPSA id u66sm7352636pfu.186.2021.03.15.18.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 18:19:20 -0700 (PDT) Date: Tue, 16 Mar 2021 10:19:19 +0900 Message-ID: From: Hajime Tazaki 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 Subject: Re: [RFC v8 12/20] um: lkl: initialization and cleanup In-Reply-To: References: <031847ceca73023566fba8e84433a615eac6a2f3.1611103406.git.thehajime@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.1 Mule/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org 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 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