Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4586450pxa; Mon, 10 Aug 2020 12:49:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfyg7Zi5wYr8l+BB7EFnr/wjww3raN9KZCBDZLTyMjpQ3wb0B1GOMde0qpyvs7PCk+aYlD X-Received: by 2002:a17:906:c7d2:: with SMTP id dc18mr24046397ejb.135.1597088945116; Mon, 10 Aug 2020 12:49:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597088945; cv=none; d=google.com; s=arc-20160816; b=NrzCc8Hp4cjKaJuchv9gagDvYR1wMmsxuDrQjwrSTDQdGaynCYLBHg5IQBDsATW6Ft vZaV4orr05+k6KRtG7c8CVMw1uMf1JAXuYBm8V927SfePmfTzt6Ij33SJtV9baCQE0oJ YSSwjDd1IuXaQ1guCmfVBTQtm4i/y0jCu8fRKOrj5Jo3M+Y8900w24E5toFOr8+7j5/0 1QmJ0ngEvpbzGEEPizMR/pgWGTbijRf47miPV6Ph7NxqDcsGBSiHAPKMCR2PDxu47EJU DaKxGb0ZrW9ZgBLgWYVWWQK3BE7Etj8hFo3csZ4Vwyq9FyLSnmbkehovyWrl0OwtNF7Q Rmwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=oRzQMCTvJ3d/F0CLCTpkBaK+ztkIxK4SeNJuOlZ33WI=; b=ns3B6Q9Q4sD04tTg/7A1ZU4wt1stwH4FeMa0a4kq7z55v+Y18SIzrxcvZEjV+hl8C8 rs1QcfJb2s3vthYbe9UzJmO7kA0C8MD6ebIeglZ6urMmXedC6KY5QSL2LCBuTcJhBSec 5/NDOFdZERaIN0+upIYlYygoKehbxLlJG2I2H1s87FwdpAKYCG18bXPYokbMCkVT5VE+ 6GVFxddDC0FR/CLw/jKwEu6lssPgsi90uF6j8glBWwNibSCiS8uar/B7URJXVB493izR 5/EBmobteQX1r3Xu/J4ZQzKnjVOT9oB5Xhc8IMFI5CYFy8rRF0aMytpO2pMmUSb3mcUQ /54Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YMpVmq+C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jr23si12119502ejb.572.2020.08.10.12.48.40; Mon, 10 Aug 2020 12:49:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YMpVmq+C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728351AbgHJTq5 (ORCPT + 99 others); Mon, 10 Aug 2020 15:46:57 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:26076 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728275AbgHJTq4 (ORCPT ); Mon, 10 Aug 2020 15:46:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597088814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oRzQMCTvJ3d/F0CLCTpkBaK+ztkIxK4SeNJuOlZ33WI=; b=YMpVmq+CqU6ZcFLCyTG4cnR/kYRlVG0+lax8JF9zCGKjay52C505XgARW/PjevF1AysAzf keZx4JkXzL5DsE/+vH8/46pQEfZ7xGypqYJ/aBqHtKwoFG6uKsaSabzfQOlEOFph53asnC AJBK0CAuIPC7p+16TMQUA/PK/w9pEw8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-142-bTE2M3asMpSHOHqjSXL1hQ-1; Mon, 10 Aug 2020 15:46:49 -0400 X-MC-Unique: bTE2M3asMpSHOHqjSXL1hQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E8B591005510; Mon, 10 Aug 2020 19:46:48 +0000 (UTC) Received: from [10.10.120.16] (ovpn-120-16.rdu2.redhat.com [10.10.120.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D09BF19C4F; Mon, 10 Aug 2020 19:46:47 +0000 (UTC) Subject: refactoring livepatch documentation was Re: [PATCH 1/2] docs/livepatch: Add new compiler considerations doc To: Petr Mladek , Josh Poimboeuf Cc: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200721161407.26806-1-joe.lawrence@redhat.com> <20200721161407.26806-2-joe.lawrence@redhat.com> <20200721230442.5v6ah7bpjx4puqva@treble> <20200722205139.hwbej2atk2ejq27n@treble> <20200806120336.GP24529@alley> From: Joe Lawrence Message-ID: <3842fe65-332e-9f90-fe75-7cd80b34b75e@redhat.com> Date: Mon, 10 Aug 2020 15:46:46 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200806120336.GP24529@alley> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/6/20 8:03 AM, Petr Mladek wrote: > On Wed 2020-07-22 15:51:39, Josh Poimboeuf wrote: >> On Wed, Jul 22, 2020 at 01:03:03PM -0400, Joe Lawrence wrote: >>> On 7/21/20 7:04 PM, Josh Poimboeuf wrote: >>>> On Tue, Jul 21, 2020 at 12:14:06PM -0400, Joe Lawrence wrote: >>>>> Compiler optimizations can have serious implications on livepatching. >>>>> Create a document that outlines common optimization patterns and safe >>>>> ways to livepatch them. >>>>> >>>>> Signed-off-by: Joe Lawrence >>>> >>>> There's a lot of good info here, but I wonder if it should be >>>> reorganized a bit and instead called "how to create a livepatch module", >>>> because that's really the point of it all. >>>> >>> >>> That would be nice. Would you consider a stand-alone compiler-optimizations >>> doc an incremental step towards that end? Note that the other files >>> (callbacks, shadow-vars, system-state) in their current form might be as >>> confusing to the newbie. >> >> It's an incremental step towards _something_. Whether that's a cohesive >> patch creation guide, or just a growing hodgepodge of random documents, >> it may be too early to say :-) > > Yes, it would be nice to have a cohesive documentation. But scattered > pieces are better than nothing. > >>>> I'm thinking a newcomer reading this might be lost. It's not >>>> necessarily clear that there are currently two completely different >>>> approaches to creating a livepatch module, each with their own quirks >>>> and benefits/drawbacks. There is one mention of a "source-based >>>> livepatch author" but no explanation of what that means. >>>> >>> >>> Yes, the initial draft was light on source-based patching since I only >>> really tinker with it for samples/kselftests. The doc was the result of an >>> experienced livepatch developer and Sunday afternoon w/the compiler. I'm >>> sure it reads as such. :) >> >> Are experienced livepatch developers the intended audience? If so I >> question what value this document has in its current form. Presumably >> experienced livepatch developers would already know this stuff. > > IMHO, this document is useful even for newbies. They might at > least get a clue about these catches. It is better than nothing. > > I do not want to discourage Joe from creating even better > documentation. But if he does not have interest or time > to work on it, I am happy even for this piece. > Hi Petr, Josh, The compiler optimization pitfall document can wait for refactored livepatch documentation if that puts it into better context, particularly for newbies. I don't mind either way. FWIW, I don't profess to be an authoritative source its content -- we've dealt some of these issues in kpatch, so it was interesting to see how they affect livepatches that don't rely on binary comparison. Toward the larger goal, I've changed the thread subject to talk about how we may rearrange and supplement our current documentation. This is a first pass at a possible refactoring... 1. Provide a better index page to connect the other files/docs, like https://www.kernel.org/doc/html/latest/core-api/index.html but obviously not that extensive. Right now we have only a Table of Contents tree without any commentary. 2. Rearrange and refactor sections: livepatch.rst Keep just about everything Add a history section to explain ksplice, kgraft, kpatch for the uninitiated? Add a section on source based vs. binary diff livepatch creation, this may be worth its own top-level section Livepatch API Basic API Callbacks Shadow variables Cumulative patches System state KLP Relocations Right now this is a bit academic AFAIK kpatch is the only tool currently making use of them. So maybe this document becomes a more general purpose doc explaining how to reference unexported symbols? (ie, how does kgraft currently do it, particularly w/kallsyms going unexported?) Eventually this could contain klp-convert howto if it ever gets merged. Compiler considerations TBD I suppose this doesn't create a "Livepatching creation for dummies" guide, but my feeling is that there are so many potential (hidden) pitfalls that such guide would be dangerous. If someone were to ask me today how to start building a livepatch, I would probably point them at the samples to demonstrate the basic concept and API, but then implore them to read through the documentation to understand how quickly complicated it can become. -- Joe