Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1937791imu; Thu, 10 Jan 2019 05:43:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN50G01v+s7WNXbS1yBQjQKdf4n8N2FbscR4Kff6inmt3lFDdpjAPL48k5SdyN5s0tszR2Sx X-Received: by 2002:a63:7154:: with SMTP id b20mr9390536pgn.342.1547127833811; Thu, 10 Jan 2019 05:43:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547127833; cv=none; d=google.com; s=arc-20160816; b=aTIAvsFp1LWT654d/sIqIVcW2wQt9Lkn+14UYab+LutamRZ7C2pYhhXYfmiqnWhs1B qcsK+MWNU6xPUR4bHbJbqNWZMkem8FsjwZ9CIiPPDkezo5AbfiicFdvDp6q50E2eSgt7 cLJSwSgAUZItX6imSILHYuadu7/Vgc4wvEEWJl4bryE5Jbl8fjGiPWeixxqdzGfcutrc VfH9czB/G8LuFY+yE4EDbSkgaE04NxkouCBmCcdVssZjbLHGYT6kyXEF2+yv57JYNIf/ 8lnXVJLcUN45F52KL3vIaHvJ7/LmL1POmYqe9zS7AtGEFSEUS/eBhbzAyMbVsPsDAzec eN6g== 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 :message-id:in-reply-to:subject:cc:to:from:date; bh=nZ+r1YqM4XA3WDIhWHG3kpfFBl0uccVEJdru4J6FV4g=; b=hBgEmxCSSnlubwbWcKucws6ulW/BseTwK7cBraZq5pYzOxQWns3K7rhfRKXEEz2aA0 WObBBo/HhFdqV3hu6lCujzaQfKU0+HzuPWK8dC5nMlOarG2jWrtAhY0A5Oa0Vuv7PI9u e9woLZVB3Qo7K2CdzPfin9cMsKrp4KxAF/ds43MA9wQo+tBZ9Sf4tHX+ABg3L2n5TWu7 mgPWW7R0RH4SIJe5/F1Os+XVfAQvsphjPa120GcPspWLHkI/4uzM56fzUi1X2sF5Wagq wuomoZJuZBhmNygbk/PgQd38Ta+pQHJL7RSWZVh7yTEZz67BHjwTmUGjWogSeiD6jsCr JfHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si17626581pll.179.2019.01.10.05.43.38; Thu, 10 Jan 2019 05:43:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728953AbfAJNmV (ORCPT + 99 others); Thu, 10 Jan 2019 08:42:21 -0500 Received: from mx2.suse.de ([195.135.220.15]:39598 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728892AbfAJNmU (ORCPT ); Thu, 10 Jan 2019 08:42:20 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0615FAD08; Thu, 10 Jan 2019 13:42:18 +0000 (UTC) Date: Thu, 10 Jan 2019 14:42:17 +0100 (CET) From: Miroslav Benes To: Petr Mladek cc: Jiri Kosina , Josh Poimboeuf , Jason Baron , Joe Lawrence , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v15 08/11] livepatch: Remove Nop structures when unused In-Reply-To: <20190109124329.21991-9-pmladek@suse.com> Message-ID: References: <20190109124329.21991-1-pmladek@suse.com> <20190109124329.21991-9-pmladek@suse.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 9 Jan 2019, Petr Mladek wrote: > Replaced patches are removed from the stack when the transition is > finished. It means that Nop structures will never be needed again > and can be removed. Why should we care? > > + Nop structures give the impression that the function is patched > even though the ftrace handler has no effect. > > + Ftrace handlers do not come for free. They cause slowdown that might > be visible in some workloads. The ftrace-related slowdown might > actually be the reason why the function is no longer patched in > the new cumulative patch. One would expect that cumulative patch > would help solve these problems as well. > > + Cumulative patches are supposed to replace any earlier version of > the patch. The amount of NOPs depends on which version was replaced. > This multiplies the amount of scenarios that might happen. > > One might say that NOPs are innocent. But there are even optimized > NOP instructions for different processors, for example, see > arch/x86/kernel/alternative.c. And klp_ftrace_handler() is much > more complicated. > > + It sounds natural to clean up a mess that is no longer needed. > It could only be worse if we do not do it. > > This patch allows to unpatch and free the dynamic structures independently > when the transition finishes. > > The free part is a bit tricky because kobject free callbacks are called > asynchronously. We could not wait for them easily. Fortunately, we do > not have to. Any further access can be avoided by removing them from > the dynamic lists. > > Signed-off-by: Petr Mladek Acked-by: Miroslav Benes Miroslav