Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5080497iob; Mon, 9 May 2022 08:14:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/j+JjVNHeMzZjhtKV+Z1hbKohuc0SxjSJTM+DB20r+4rY9uzap/Oqv0D+AjjYB/hxklRI X-Received: by 2002:a17:90b:3ecb:b0:1dc:5401:bea with SMTP id rm11-20020a17090b3ecb00b001dc54010beamr18391426pjb.20.1652109254922; Mon, 09 May 2022 08:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652109254; cv=none; d=google.com; s=arc-20160816; b=jzJ/ARnG5XtctnVk1JXhIpGgt8z+JPklFmg4FsF9bpSiJPAusU1SkbsxoIxc5vIFMY Vagpr0ntv7FeHc9mzfRLsa3/GUKs4OjP7ox+Vi7ePEMBj/zghiOV25C7BF+EpkZgpFZ9 r7JbihZEW9yli9K1eLBYEvKu16czt5MDF+8SGe5t9Q6xG5lBTavPXgUX7i9Ye916a4A0 KS/J4JvCi+mdVu6eCIk95SetoEqiZ+ZMroAWq5nwoa4cVJQ/HGBFUP50Ed/fNdd86IBc VNqBBBOtAS+/cLcF+hNcLl6xTJ/WEXOLwWmXTIXOG72ypEUB/KjCtY/2PZ3iGE83rFCK eL+w== 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=9gqDS5q/MKc74BdYPGpBWDc3d446H1BDCKvzO0bJI4k=; b=1KHY/PQCirPHGWlfzvA44NahibdzqTxUODu1HmckHs3SelkoGyTTto+24NEoV1SE/8 xKnr3qz+yqHXN/SOMNu30QovJ2HFvuECP3+ochSDHb5hpAUltqSO7DeWfDAxXf/V7O1J QuPVDV8JSf6MUcW9gN3wmWJjVn5OLy9c9tyHdBYaPItttiJyAJpOUhDIXOgXYZvSCDXD OCiPiDezaXCw0NsOUjtmCpsQGkLDuD0aTVO34rdHpd2jFCIUHtfELH17l9rtOVMYQtQF GRQvsvuByKSAOXvVriW8Quejc8cC9SsI0xg2QzlTfogfHtOb2GotvlFBXCmNqWe+uUzA jo2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="Qn6WT/0i"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 1-20020a630101000000b003c6779f73eesi9084992pgb.530.2022.05.09.08.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 08:14:14 -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=@suse.com header.s=susede1 header.b="Qn6WT/0i"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 02F842C122; Mon, 9 May 2022 08:07:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238158AbiEIPLN (ORCPT + 99 others); Mon, 9 May 2022 11:11:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238081AbiEIPLD (ORCPT ); Mon, 9 May 2022 11:11:03 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70D67289AE; Mon, 9 May 2022 08:07:06 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 9018F1F953; Mon, 9 May 2022 15:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1652108825; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9gqDS5q/MKc74BdYPGpBWDc3d446H1BDCKvzO0bJI4k=; b=Qn6WT/0iH8XKFNs88aKfKy7QSFhbERAl+NzJ7IWEcySAlsNYgNV9xOzToGe6+sXxBkhI1h 5FIDvWW5IFIcWCx5XKIpiQERUjAVdb5Pi9VB5aD7o0AZq/g5HAa9+7+ZZGkX075uuX14b4 GqSMwQtg+RE8+GiNN1588iZmFUY6zIc= Received: from suse.cz (unknown [10.100.201.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 698B92C141; Mon, 9 May 2022 15:07:05 +0000 (UTC) Date: Mon, 9 May 2022 17:07:02 +0200 From: Petr Mladek To: Song Liu Cc: 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 klp_try_switch_task in __cond_resched Message-ID: References: <20220507174628.2086373-1-song@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220507174628.2086373-1-song@kernel.org> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 On Sat 2022-05-07 10:46:28, Song Liu wrote: > Busy kernel threads may block the transition of livepatch. Call > klp_try_switch_task from __cond_resched to make the transition easier. Do you have some numbers how this speeds up the transition and how it slows down the scheduler, please? cond_resched() is typically called in cycles with many interactions where the task might spend a lot of time. There are two possibilities. cond_resched() is called in: + livepatched function In this case, klp_try_switch_task(current) will always fail. And it will non-necessarily slow down every iteration by checking the very same stack. + non-livepatched function In this case, the transition will succeed on the first attempt. OK, but it would succeed also without that patch. The task would most likely sleep in this cond_resched() so that it might be successfully transitioned on the next occasion. From my POV this patch this patch brings more harm than good. Note that scheduling is a fast path. It is repeated zillion-times on any system. But livepatch transition is a slow path. It does not matter if it takes 1 second or 1 hour. Best Regards, Petr