Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp948260pxp; Wed, 16 Mar 2022 22:18:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6875dePqj93ceopicTajkgddPLyzLXvYe5L7qZ8zYoCEt9J5+POUm6LpMMNRuNAbTeubq X-Received: by 2002:a17:903:2051:b0:151:d161:f0a4 with SMTP id q17-20020a170903205100b00151d161f0a4mr3390484pla.37.1647494296768; Wed, 16 Mar 2022 22:18:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647494296; cv=none; d=google.com; s=arc-20160816; b=sBDhjkMsm0c7nOqhG/JihnSz4oofuIE0s73Oml9xFPtyWT9NufSHEnF1S7acE8qdz+ oxlyjm3OPiFcrb/id8N7O75pFuVQbQTl94+z3n1n/GUNS9fkC1bNK/UXndnDDV1HY/gV LEkMJy9zKUCUVOlza8EYgNsX1t2q+j30MS4ojPyz2CZ/dt/77XatCoR3tt93ap2DAOZn aNZvJ39e7hP686Yuz26j/PhCUpjOxJt+iSZbQGgavxNfFzIu0k0ZM8bKoDlzFhlk9cs7 qjc0fAmgr0Ke6OBUrWceu1p/S4SNc81DpSIkvzWETf2jq5pJBmm+8pR/IBW8ky3nThyJ z/eA== 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=XaTng22aYFlv7NgcIe0v1KHMxXuvJ+qQDDO9xj7QADM=; b=ciMmnkzbrZNSmxTs6/8Xm+1ViH8jKrZjbnAmMVTDSZvi9YNJT7ck/UT0D3p9I0G8nZ gyfGVq3my3Ab8Ot63YbodfXiLx2SkBv7MGpWF+H4dAX/2pi05eRljLp++yevV2yF8/Mm 39fDygS8ewrE79NjdQOSmuavFBIDeIEieK0ClvIfAmfiaO3q8dQbPEMTnEg9em61mes8 n6WnItyaAKfz+F7vtb6vE5X8vxBhDXiseOrVW9hvdjPL73V3KcGUz2ZTY2xwzXbiOmlI vHh3mAyPFAj8iuxsjnAWgAoy933Da802IDopqrOH7SZQdsx/Kd5PlKqol6i/ykfw6E3r ktiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=UbQZbfx+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n12-20020a170902d2cc00b0015333c9bdd1si3791515plc.490.2022.03.16.22.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:18:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=UbQZbfx+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 5C3601EDA2D; Wed, 16 Mar 2022 21:25:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239537AbiCPPCX (ORCPT + 99 others); Wed, 16 Mar 2022 11:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231613AbiCPPCW (ORCPT ); Wed, 16 Mar 2022 11:02:22 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E23422BE3; Wed, 16 Mar 2022 08:01:04 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id ECF4E21123; Wed, 16 Mar 2022 15:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1647442862; 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=XaTng22aYFlv7NgcIe0v1KHMxXuvJ+qQDDO9xj7QADM=; b=UbQZbfx+JBsqITI8XSIZo49f/OYrzBsHhdFBiKt+N4P1igy2NUGhIofHT4pxJ0rWzB4ctP 5Dv/rTBX+71DSJO1UNXbbLgrMu1y9ctA6fIhDKl7lsloZrGRH+T2YivKSvivFAcQvPKPPY wUb87PZ21wUAa95jeKIcpwWSMzncygk= Received: from suse.cz (unknown [10.100.216.66]) (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 9683FA3B89; Wed, 16 Mar 2022 15:01:02 +0000 (UTC) Date: Wed, 16 Mar 2022 16:01:02 +0100 From: Petr Mladek To: Miroslav Benes Cc: Chengming Zhou , jpoimboe@redhat.com, jikos@kernel.org, joe.lawrence@redhat.com, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, songmuchun@bytedance.com, qirui.001@bytedance.com Subject: Re: [PATCH v3] livepatch: Don't block removal of patches that are safe to unload Message-ID: References: <20220312152220.88127-1-zhouchengming@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Wed 2022-03-16 15:48:25, Miroslav Benes wrote: > On Sat, 12 Mar 2022, Chengming Zhou wrote: > > > module_put() is not called for a patch with "forced" flag. It should > > block the removal of the livepatch module when the code might still > > be in use after forced transition. > > > > klp_force_transition() currently sets "forced" flag for all patches on > > the list. > > > > In fact, any patch can be safely unloaded when it passed through > > the consistency model in KLP_UNPATCHED transition. > > > > By other words, the "forced" flag must be set only for livepatches > > s/By/In/ > > > that are being removed. In particular, set the "forced" flag: > > > > + only for klp_transition_patch when the transition to KLP_UNPATCHED > > state was forced. > > > > + all replaced patches when the transition to KLP_PATCHED state was > > forced and the patch was replacing the existing patches. > > > > index 5683ac0d2566..7f25a5ae89f6 100644 > > --- a/kernel/livepatch/transition.c > > +++ b/kernel/livepatch/transition.c > > @@ -641,6 +641,18 @@ void klp_force_transition(void) > > for_each_possible_cpu(cpu) > > klp_update_patch_state(idle_task(cpu)); > > > > - klp_for_each_patch(patch) > > - patch->forced = true; > > + /* > > + * Only need to set forced flag for the transition patch > > + * when force transition to KLP_UNPATCHED state, but > > + * have to set forced flag for all replaced patches > > + * when force atomic replace transition. > > + */ > > How about something like > > /* > * Set forced flag for patches being removed, which is the transition > * patch in KLP_UNPATCHED state or all replaced patches when forcing > * the atomic replace transition. > */ Or just the first sentence: /* Set forced flag for patches being removed */ The rest is visible from the code. Either version works for me. If we agree on it then I update the text when pushing the patch. Best Regards, Petr