Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp957769iob; Fri, 13 May 2022 17:42:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/b/DnzQB6c9rewliOYYUNF5LeZxBUJ94LgW62L5z+twjLn1oq8QbQVvgWkOw05XfJ1orR X-Received: by 2002:a05:6000:1681:b0:20c:5aa2:ae14 with SMTP id y1-20020a056000168100b0020c5aa2ae14mr5876023wrd.443.1652488920037; Fri, 13 May 2022 17:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652488920; cv=none; d=google.com; s=arc-20160816; b=lsb2gSTl0DGrV6eVDr9F5Ie1HXBprgvMyqnUkMI0e1VCGRVI9JOgELeLDOjx254g9r huV0uEeAj1wc1hEYGG5QsCc6EdN4TqvtC4f1uKFFzG/Uk9EvW2IVV7xOEfvcOXN7bj41 nLrOfXsmzqSrkeF+4Sgd8yomlHsqvah+ccQl62fRKsbeFXq5NO2/eoN3qpPHtTy7F3Sn q61cLalv876/ffwRuGAqmAZHt1ROQ25qf3EG14rdOPv/n1Bi1WuaWeK4BfbEbPx9+SxP 1PcM5Sxjr4OTurxUmrb57VG2/U5BWu1DnUYZJ1aKsmL6tuv9has1KKmEgZxffpIkl3XK mJ9Q== 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=IkV5p/ApK8n1ufpYV7285quabg/Wbn9M/aPtlH0DTUU=; b=TEE2KaicS23UN+sGukG/d36uaZQMvxQX9Y0oCHtoorsb5gPOZSaIBw8L6n212KZ3vV x9fz0d3FnxOOiN8TxVmYjBQIQoPhEdpAbLOodTK93jy2ilx8EC6qRd4GEYYe7tVsgXWr zCdBcdknbl9f3+1+5ACn6LidANXOh3HEgqHii/wcbC0PQmfATsFqLwjVL0/fMsgfL7b7 ftwWeiT2EVni25rxGP+nXLY4d7l39CqaURdGQfXgmfdznFUtNIgb2EoGipvfcydOh5pN RV9An6g1L12RrZrYQ05EMD2pNEJzjTX/G0LXVighxr3+f9Lcf0xsGcaLMa23A/s3sXC8 6heA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pnyzTZPV; 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 e7-20020a5d6d07000000b0020c617ab0a8si4361349wrq.813.2022.05.13.17.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 17:42:00 -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=pnyzTZPV; 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 D2301BC6C9; Fri, 13 May 2022 16:22:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345623AbiELEII (ORCPT + 99 others); Thu, 12 May 2022 00:08:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237704AbiELEIF (ORCPT ); Thu, 12 May 2022 00:08:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C0421C1944; Wed, 11 May 2022 21:07:59 -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 ams.source.kernel.org (Postfix) with ESMTPS id 1C9A1B826EB; Thu, 12 May 2022 04:07:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A9DBC385B8; Thu, 12 May 2022 04:07:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652328476; bh=nToCYq4DpbQJGzgxLKbxS08A3TEqWAxzTo6AdzETI/M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pnyzTZPV0KHLm1PzsbwJPizzvHeVHP2MhHeBLOxpQbNY3/5lwkmSbs4XPsvIJkla7 EGT6amNGEP2JYeF/4E/FB7nWLHXZyawMsM5YwsqBsSvuBY8ZDys6XyFdFu6KgAXIA/ MGjnP/9HazBbe3k9kChXuQ6Dbuf/E8JvxpzpJRdEwaxDy8x4+10xejVf28ZzMqa52r jcw54bZiITfexxCVXF153RAcerOfO59enG8GvxFKVM/bfDfvqwXCLgik68o0sUvgTl Q+MViQYmuzdAwYtGy140V6+wjbSPGSGGNXT8uGE0giieWkp2CdieG0sIsOSZ3m0cLA c4miDokqgQPSA== Date: Wed, 11 May 2022 21:07:54 -0700 From: Josh Poimboeuf To: Song Liu Cc: Petr Mladek , Rik van Riel , "song@kernel.org" , "joe.lawrence@redhat.com" , "peterz@infradead.org" , "mingo@redhat.com" , "vincent.guittot@linaro.org" , "live-patching@vger.kernel.org" , Kernel Team , "linux-kernel@vger.kernel.org" , "jpoimboe@redhat.com" Subject: Re: [RFC] sched,livepatch: call klp_try_switch_task in __cond_resched Message-ID: <20220512040754.hcnip7d2rhp4ldgg@treble> References: <6bf85ff908377508a5f5bcc7c4e75d598b96f388.camel@fb.com> <20220510165244.ikfh64ertnvodxb4@treble> <1bd15361edfd4db9fc9271d35e7bbe5edad1b87a.camel@fb.com> <20220510184213.l3gjweeleyg7obca@treble> <47440502-930F-4CBD-B859-3AC9BBFF8FC6@fb.com> <20220510230402.e5ymkwt45sg7bd35@treble> <20220511003331.clfvwfgpmbr5yx6n@treble> <20220511092433.GA26047@pathway.suse.cz> <78DFED12-571B-489C-A662-DA333555266B@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <78DFED12-571B-489C-A662-DA333555266B@fb.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 Wed, May 11, 2022 at 04:33:57PM +0000, Song Liu wrote: > >> Ideally we'd have the ORC unwinder for all arches, that would make this > >> much easier. But we're not there yet. > > > > The alternative solution is that the process has to migrate itself > > on some safe location. > > > > One crazy idea. It still might be possible to find the called > > functions on the stack even when it is not reliable. Then it > > might be possible to add another ftrace handler on > > these found functions. This other ftrace handler might migrate > > the task when it calls this function again. > > > > It assumes that the task will call the same functions again > > and again. Also it might require that the tasks checks its > > own stack from the ftrace handler. I am not sure if this > > is possible. > > > > There might be other variants of this approach. > > This might be the ultimate solution! As ftrace allows filtering based > on pid (/sys/kernel/tracing/set_ftrace_pid), we can technically trigger > klp_try_switch_task() on every function of the pending tasks. If this > works, we should finish most of the transition in seconds. And the only > failure there would be threads with being patched function at the very > sottom of its stack. Am I too optimistic here? It's a crazy idea, but I kind of like it ;-) Especially this variant of tracing all functions for the task. We'd have to make sure unwinding from an ftrace handler works for all arches/unwinders. -- Josh