Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5212234iob; Mon, 9 May 2022 11:04:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDdBdoo5LjwyNZSwZaU810AMthaE+mhSam9VDOIPRZ5Fx8LRfJ0QeLiIzPHzSODeO3gxMJ X-Received: by 2002:a05:6214:d87:b0:45a:bb62:fa24 with SMTP id e7-20020a0562140d8700b0045abb62fa24mr14276355qve.71.1652119472262; Mon, 09 May 2022 11:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652119472; cv=none; d=google.com; s=arc-20160816; b=iV3AAiLbYGtXHH8x285LUiRtCJ1olqD4U5PDVtpzdowJDwu7nw+wlkHMDYze6Spc53 BVEVlFfR+CNgPAVifJ5lzCocc3jKEN719Df1Ed226vIxLymq4/dQyL1HjcSzuHmJJ3sX W9Iz9Z2JhpUUdlGdTA4smtDqSbAnpyQBu5A+ubLZCWSOpu593DzrpkLdsg9ZkjgLUoRd AuVBzbm4ZEfWmAg3+4gIyz9C8pal+Ai058ouTVo45y/D9MYpruF2YO6/8MTSW1bDUPjX nwZgumDx2PmZ2tkNcBp72iJXrMtmhHvD/FxW9SzkPfHsChWRxLkUDOzw4C4B6xDH3c8H lXuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0a4HDrSO7BbSs0KyMtuInXyU2l2aPwi5m8m8aDQJIX0=; b=D4ZSEJ1eG5bIPC9wZjQ+n2vsh5kREPTC0uqS/45GN6S4VOe9QNtceE8lREPOdTDw0S KOpV/DEyp50hC+nLeHutAQhPWso8Yo/EpXe7+nW1IdG5eD8/kIpI2WicmGaI3+PLlhxE ovRTZ7Q2aaed2kK7bmkB9kwJCkZZTJPg7q1ByI1pOzzEJqoMmvL1j4eFoW9tllHkF+2b J7e3yopo6h8AbM1y4+M5+L/gaV2Fv/g/8YG4U8V8KW1dYy5JTwvHh1w4e9ZAEcjT6Esp 9UktDN0HFw8/h5NbfkOlaTu1MXncsQoRPKVuXw0Lue6Y0GUG7wzPm+vViUmugfnaCj3c r1FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z2PsqCWA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z18-20020a05622a061200b002f3c48d76b5si8375919qta.297.2022.05.09.11.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 11:04:32 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z2PsqCWA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7B0D923675A; Mon, 9 May 2022 11:00:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239912AbiEISEH (ORCPT + 99 others); Mon, 9 May 2022 14:04:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239925AbiEISEE (ORCPT ); Mon, 9 May 2022 14:04:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A16522A2F9; Mon, 9 May 2022 11:00:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 989E0615D7; Mon, 9 May 2022 18:00:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 970D7C385B2; Mon, 9 May 2022 18:00:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652119207; bh=+6bV93j1JQUzPiPeS8iW/xrGtw1Q0Og6QhFnv7F7R9o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Z2PsqCWAw810MTRoGUm/er10ah2EoSb8C3TIGr0VVdrDmjwgg/sscRHBpjkY3W7jM VhsZ9+kX73Xe+ftMhQnNipnQvsP/30DiVxzTZGYa2jfaUN9MukhesI6yzuyk/rR/kO L3XW8VteSAYo6nK3bPwi1L5nJAS7JzUj+p/08wT9/KUujrggG25DvydboTo417/4Xh wtncttQe3b6xivcbNmQouhyr3qQDCu2swo9sUlPMAxeKDUnp00/e1qgYQ3B9Yfvn1G 07wOnSoD7D6g8j0Y14JmRtnuSEwroJDw34//38KD+1ko2mETo4AZBKh1vPtaT0dvAl FMSGt6tUD9gKA== Date: Mon, 9 May 2022 11:00:04 -0700 From: Josh Poimboeuf To: Rik van Riel 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 Subject: Re: [RFC] sched,livepatch: call stop_one_cpu in klp_check_and_switch_task Message-ID: <20220509180004.zmvhz65xlncwqrrc@treble> References: <20220507174628.2086373-1-song@kernel.org> <20220509115227.6075105e@imladris.surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220509115227.6075105e@imladris.surriel.com> X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Mon, May 09, 2022 at 11:52:27AM -0400, Rik van Riel wrote: > Does this look like an approach that could work? > > ---8<--- > sched,livepatch: call stop_one_cpu in klp_check_and_switch_task > > If a running task fails to transition to the new kernel live patch after the > first attempt, use the stopper thread to preempt it during subsequent attempts > at switching to the new kernel live patch. > > It would be helpful to add more info about the original problem being solved, and how this is supposed to fix it. > +static int kpatch_dummy_fn(void *dummy) s/kpatch/klp/ > +{ > + return 0; > +} > + > /* > * Try to safely switch a task to the target patch state. If it's currently > * running, or it's sleeping on a to-be-patched or to-be-unpatched function, or > @@ -315,6 +321,9 @@ static bool klp_try_switch_task(struct task_struct *task) > case -EBUSY: /* klp_check_and_switch_task() */ > pr_debug("%s: %s:%d is running\n", > __func__, task->comm, task->pid); > + /* Preempt the task from the second KLP switch attempt. */ > + if (klp_signals_cnt) > + stop_one_cpu(task_cpu(task), kpatch_dummy_fn, NULL); I must be missing something, how is briefly preempting a kthread supposed to actually transition it? Won't it likely go back to running on the CPU before the next periodic klp_transition_work_fn() check? -- Josh