Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5263479iob; Mon, 9 May 2022 12:15:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLCIYA/adSBpcU2aTC4D6MJGVnNwx6pjpGCKgoOdyl0d9XonyrCWFd9mVoBEc3o8jG7ALN X-Received: by 2002:a17:90b:3d0:b0:1d9:52e1:de86 with SMTP id go16-20020a17090b03d000b001d952e1de86mr27425688pjb.73.1652123724987; Mon, 09 May 2022 12:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652123724; cv=none; d=google.com; s=arc-20160816; b=fiAc2BR5l2Q0qPWvE/cnj7yfyHcvSfCvSTsWAmcDD/inNMXja6kG8SmLeBvaXARuHA yVlH2IbMnP10Te0vpbZ7OyofQ5iENgl8fsg1K1WZ9DGcZODe4NdJH9Q4s2lXLrmUHv4g 7cS9HjXLq06y8o7ogIuvszOYt4BvtYhdlE6kbQ/jzazBeDmCpwiGkKYGiQPHm8hxedw7 120bXhjtpP5vaakxFomdvDTdSnBRHmGe6HFw8p0CV5pz7OapzcK2FCjiUbYe9D88q3PK EkbYNz3BGqnRWPu3NDwZaM/BgbJD2xlaUJ+09kqdix1+o7WIAY6lvJ/YPvE/A3TZEmT3 Boew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id; bh=m2TossFp+KbwdAUb3VjEwUtcKD0zGx1/JZpRgmOc3tE=; b=nmngnBYxgOVfyWn/N/uLWQ9ksKZQQ6vQSvzdyw3cBNEai8RfTV9Vqvzvfl7KJFx/cH Al8ZNG+lFoMPIspbe4hXcJKQuh1fVGcyO5YRDAT3fL9tc4Cj77YxizaBzpKr2UN2yLfx iSE6WQDO3xpR8cHnNwbsnnbGGUN//XkzXX+9GXezZPVsFcdgtcofp920XW/y95BI5BSc vYjkaJQk+Xj9sRLvb6DSnykJXE66AB4VhcWOWCS5GWKH1D+MLw3DUWuaTA2YUb4c/lKL lsm3MzpPr6Qsr/6RCg/TVuzw7j1OHWzcWTNn2MRGhqjO9BrlxBOMeOMFIJPLlvtfGTSp SMbw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u6-20020a63ef06000000b003c1a428e951si15327894pgh.53.2022.05.09.12.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 12:15:24 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2F3222D2E29; Mon, 9 May 2022 12:10:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240455AbiEITOW (ORCPT + 99 others); Mon, 9 May 2022 15:14:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240446AbiEITOV (ORCPT ); Mon, 9 May 2022 15:14:21 -0400 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB64C293B79; Mon, 9 May 2022 12:10:26 -0700 (PDT) Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1no8lt-0002U9-KO; Mon, 09 May 2022 15:10:17 -0400 Message-ID: <68f91fb233d5bf82e29cc5c6960a62863b297db3.camel@surriel.com> Subject: Re: [RFC] sched,livepatch: call stop_one_cpu in klp_check_and_switch_task From: Rik van Riel To: Josh Poimboeuf Cc: Song Liu , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, vincent.guittot@linaro.org, jpoimboe@redhat.com, joe.lawrence@redhat.com, kernel-team@fb.com Date: Mon, 09 May 2022 15:10:16 -0400 In-Reply-To: <20220509180004.zmvhz65xlncwqrrc@treble> References: <20220507174628.2086373-1-song@kernel.org> <20220509115227.6075105e@imladris.surriel.com> <20220509180004.zmvhz65xlncwqrrc@treble> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-8fjrMtbSQtuvFTIamLXF" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 Sender: riel@shelob.surriel.com X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-8fjrMtbSQtuvFTIamLXF Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 2022-05-09 at 11:00 -0700, Josh Poimboeuf wrote: > On Mon, May 09, 2022 at 11:52:27AM -0400, Rik van Riel wrote: > > Does this look like an approach that could work? > >=20 > > @@ -315,6 +321,9 @@ static bool klp_try_switch_task(struct > > task_struct *task) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0case -EBUSY:=C2=A0=C2= =A0=C2=A0=C2=A0/* klp_check_and_switch_task() */ > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0pr_debug("%s: %s:%d is running\n", > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= __func__, task->comm, task->pid); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0/* Preempt the task from the second KLP switch > > attempt. */ > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0if (klp_signals_cnt) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0stop_o= ne_cpu(task_cpu(task), > > kpatch_dummy_fn, NULL); >=20 > I must be missing something, how is briefly preempting a kthread > supposed to actually transition it?=C2=A0 Won't it likely go back to > running > on the CPU before the next periodic klp_transition_work_fn() check? >=20 That's the kind of feedback I was hoping for ;) I looked around the code a little bit, and it seems that only the idle tasks can transition to another KLP while they are running? That makes me wonder how the kworker thread that runs the klp switching code transitions itself... Should kernel threads that can use a lot of CPU have something in their outer loop to transition KLPs, just like the idle task does? --=20 All Rights Reversed. --=-8fjrMtbSQtuvFTIamLXF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAmJ5ZxgACgkQznnekoTE 3oMAbQf/atY56IVjx2ggJ6AXEZS/hq956KtUV6M0CHWL4+JGly/8Y+CFt/FDHy6U 00r89Uty7vv6OxL++mjjfOGg7o9FGDogg1dIqRaQwX++uXk493ixmvlQE77g6WtJ lfk+pOtJyDwUaEiJkwHjv7MCbQBYBiwwZB4eZH/mlMwo1xNt8ten1YOOGojRmDfv hwxvs25AHNIDv3PUIK5YuyBR7n6/bkUgh3Wuw1zj8kQ05LgcM4obHLvjDvFcBLRW TbmyFC8ODY1Vq3gcWieLAlmPG9vkgzI/ESE8OYIg90xGfChbwUE8hQPrqZO5z3Y4 /n2eqP2EBSmCD7g0cz25Ite2R82cgQ== =+Vcf -----END PGP SIGNATURE----- --=-8fjrMtbSQtuvFTIamLXF--