Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1458599rdg; Sat, 14 Oct 2023 03:14:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLYNGJMcbX4OwA5OcealnbpJAHa5gkB9XZjgNRwwFqmQqUQSWMrFYThrFZwyi0pV5PWVHT X-Received: by 2002:a05:6a20:3c88:b0:14c:910d:972d with SMTP id b8-20020a056a203c8800b0014c910d972dmr31188908pzj.12.1697278498871; Sat, 14 Oct 2023 03:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697278498; cv=none; d=google.com; s=arc-20160816; b=aNXjuN3i9T+Y9Vvbiib9EDhF47rultRPORvJ8iwoqLlp++1c8wIFHdk0zgZhT8ckvW LAzDiKkPmf9E2jP0CUG5tWUA9EB4TbELFjU3QEqAyAHPJZ9G37/RDGs4L0cR59ap9L/x MJckwcPaP0rQfCtYmXNkNcordZU9xBeDa1+VLxiyEGz0udrQuf4xBl1QQ0nDJWLmxDTn uSWZpayfJ24TCFy+dxTtMk8im0NAE6G82LU89i1npEVmFMhx4YtT6qPe5KVT6DsMt7vL QxYH9TuasWGyUumjLJK2+FYmHVFiEZkfWgIelxcMiC3z3nY0IISM4rVqIkDZboWgsmio lwbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=UUBTdp68Mg0j7X33/nYaV593In1PFThvwl615KW5aSY=; fh=RkGxicj77JpW4U6evM1/rm2wQtfpdmfdDm68na0i9hY=; b=H7DNUtGE/iqTzIo+7ywZcbjSViAXPli7cP/43TWdyYGiCgZkvKvhT01u/LlUNL8WCp Zqc5EIcOXiTVMYRQBzlE1g9vxQ7UXaCXhtcoll0xOg8u8XD1Yc2VlrLD/cAa4pXSQWii eAwHaEzJQ3jWI1ykrrxIzWyXlKbTmJzolNc924N5YH85fPczCOKZ+An48rr+zpJeR8lU 1FNXroy4dIY2nqV3Ea00JPnD2d9TA1ydK2w/lG8sT2RWfR4iqKcG6qcXIMYug2VdZmsz NnfNwiWTt2Btu1odVa9p/6IZrHn4jVZe6D1wKOvdhRYUiOz3FXPzfWx0+SkCiXuXXIcH Lngg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id z18-20020a170903019200b001c752a540cdsi6676618plg.145.2023.10.14.03.14.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 03:14:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 28F0B805090A; Sat, 14 Oct 2023 03:14:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233018AbjJNKOb (ORCPT + 99 others); Sat, 14 Oct 2023 06:14:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232937AbjJNKOa (ORCPT ); Sat, 14 Oct 2023 06:14:30 -0400 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 87EFBA2; Sat, 14 Oct 2023 03:14:23 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 39E9hKnS020954; Sat, 14 Oct 2023 11:43:20 +0200 Date: Sat, 14 Oct 2023 11:43:20 +0200 From: Willy Tarreau To: Vegard Nossum Cc: Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, backports@vger.kernel.org, Harshit Mogalapalli , Bagas Sanjaya , Greg Kroah-Hartman , Stephen Rothwell , "Jason A . Donenfeld" , Konstantin Ryabitsev , Steven Rostedt Subject: Re: [PATCH v2] docs: add backporting and conflict resolution document Message-ID: <20231014094320.GC20662@1wt.eu> References: <20230824092325.1464227-1-vegard.nossum@oracle.com> <87bkdfg2ds.fsf@meer.lwn.net> <877cnu5jy0.fsf@meer.lwn.net> <83fd1a05-974e-4d91-82b0-c09cc2f8da1e@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <83fd1a05-974e-4d91-82b0-c09cc2f8da1e@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sat, 14 Oct 2023 03:14:56 -0700 (PDT) Hi Vegard, On Fri, Oct 13, 2023 at 05:24:31PM +0200, Vegard Nossum wrote: > I've now added Steven Rostedt and Willy Tarreau as well on the > off-chance that they have something to say about it (Steven presented > his conflict resolution method at Kernel Recipes and I think Willy is > experienced with backporting), but this is in no way meant as pressure > to review this patch. Here's a link to the top of the thread: > > https://lore.kernel.org/all/20230824092325.1464227-1-vegard.nossum@oracle.com/ That's a very nice description, I'm sure it can help (and I learned a few points there already). There are a few points I'm not seeing there, though, base on my habits: - in my experience, there's a huge difference between backporting code you don't know and code you know. I'm dealing with haproxy backports several times a week and I tend to know this code, so I use my intuition a lot and have no problem adjusting stuff around the conflicting parts. However when I was dealing with extended kernels, that was not the case at all, because I didn't know that code, and worse, I wasn't skilled at all on many of the parts I had to deal with. While it's OK to take the blame for a failed backport, it's generally not OK to expose users to risks caused by your lack of knowledge. In this case it means you need to be extra cautious, and very often to actually *ask* authors or maintainers for help. If maintainers do not want to help backporting some patches to an older version of their code, usually it should be perceived as a hint that they'll find it complicated to do it right; then take that as a hint that there's little chances you'll get it right by yourself while ignoring that code. This may imply dropping the fix, documenting the area as broken, or asking for help on various lists until someone more knowledgeable can help. - the tool that helped me the most in resolving rename conflicts is "patch". As you explained, "git am" is a bit stubborn. But patch is way more lenient (and will often do mistakes). In the very old 2.6.32 I used to rely on "git show XX | patch -p1" way more often than "git am". For a rename, you do "git show XX -- file |patch otherfile". It works the same with file-based patches or mbox: "patch -p1 < mbox". Patch however will not place the conflict markers and will leave .rej files. I then opened them in an editor next to the file to edit, to locate the area and copy the relevant part to its location. Emacs' ediff is also extremely convenient to pick select parts of each file. - control the patches: after I'm pretty sure I have resolved a patch, I compare it side by side with the original one. Normally, backported patches should have the same structure as the original. Using whatever editor supporting a vertical split helps a lot. Otherwise I also use "diff -y --width 200" between them to focus on differences (typically line numbers). It's not rare that a part is missing, either because I messed up, or because I forgot to process a .rej that I mistakenly removed, or because a file was added, I reset the tree and it's left untracked. So any difference between the patches should have its own explanation (line numbers, function names, file names, occurrences). By the way, it can very easily happen that applying a patch will work fine but it will apply to the wrong function because some code patterns especially in error unrolling paths are often the same between several functions. It happened to me quite a few times in the past, and even a few of these persisted till the public patch review. That's really a risk that must not be minimized! - something quite common is that as code evolves, it gets refactored so that what used to appear at 3 locations in the past now moved to a single function. But when you're backporting, you're doing the reverse work, you're taking a patch for a single location that may apply to multiple ones. Often the hint is that the function name changed. But sometimes it's not even the case. If what you've found looks like a nasty bug pattern that looks like it could easily have been copy-pasted at other places, it's worth looking for it elsewhere using git grep. If you find the same pattern, then you search for it into the tree the patch comes from. If you don't find it, it's likely that you'll need to adjust it, and git log is your friend to figure what happened to these areas. Note that git blame doesn't work for removed code. If you find the same pattern elsewhere in mainline, it's worth asking the patch author if that one is also an occurrence of the same bug or just normal. It's not uncommon to find new bugs during a backport. - color diff: usually I just rely on: [color] ui = true But I also recently got used to using diff-highlight that will highlight different characters between lines. It's nice for complex "if" conditions where you don't see the difference, or for spaces vs tabs: [pager] log = /usr/doc/git-2.35.3/contrib/diff-highlight/diff-highlight | less show = /usr/doc/git-2.35.3/contrib/diff-highlight/diff-highlight | less diff = /usr/doc/git-2.35.3/contrib/diff-highlight/diff-highlight | less - git add, git add and git add: when fixing patches by hand, it's very common to leave some parts not added (especially with | patch -p1). It's useful to work on a clean tree to more easily spot untracked files with "git status". > I feel like in the worst case, somebody sees the document down the line > and vehemently disagrees with something and we either fix it or take it > out completely. No I don't disagree and even find it useful. If at least it could help people figure the pain it is to backport any single patch, and encourage them to help stable maintainers, that would already be awesome! > I'd like to add that my impression is that a LOT of people *fear* > backporting and conflict resolution -- and it doesn't have to be that > way. We should be talking about merge conflicts and what good workflows > look like (one of the reasons why I was very happy to see Steven's > presentation at KR), instead of leaving everybody to figure it out on > their own. This document is my contribution towards that. I'm not completely sold to this. Yes we should teach more people to perform that task themselves. But there's a big difference between backporting a few patches and feeling like you could maintain your own kernel because now you know how to resolve conflicts. What I mentioned above about dealing with patches you don't understand must not be underestimated, that's the biggest challenge I faced when working on stable kernels. There's probably a feeling of shame of not understanding something, but I can say that many times I asked for help and was helped even by top-ranked developers, and nobody ever laughed at me for not understanding a certain area. But doing that in your garage for your own kernel or for your company's products is a huge problem because it's unlikely that you'll get help from the maintainers this time, so you're left on your own with your own understanding of certain patches. Thus, yes to backports, no to kernel forks being a collection of backports. > > > - Colordiff looks cool, but I'd at least drop in a mention of the Emacs > > > ediff mode, which offers (I believe) a lot of the same functionality. > > I don't use emacs personally, but I would welcome this addition if > somebody were to write it! There's not much to write about it. You start "ediff-buffers" between two files, or you can probably find "ediff" in one of the menus, or type "ediff" then press tab to get the list of commands. It's not always completely intuitive but easy to remember, and fully interactive and supports rolling back operations. Hoping this helps, Willy