public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: jikos@kernel.org, Linus Torvalds <torvalds@linux-foundation.org>,
	oneukum@suse.com, kernel list <linux-kernel@vger.kernel.org>
Subject: Re: 5.12-rc1-dontuse: Detecting known-bad commits to prevent bisect disasters
Date: Wed, 10 Mar 2021 12:40:54 +0100	[thread overview]
Message-ID: <20210310114053.GA9028@amd> (raw)
In-Reply-To: <20210310111039.GA7890@amd>

[-- Attachment #1: Type: text/plain, Size: 4526 bytes --]

Hi!

I forgot to Cc lkml... Fixing that now.

Best regards,
							Pavel

> Would there be interest in a tool to detect known-bad commits
> automatically?
> 
> Something like this?
> 
> ".known-bad" file would have to be copied out of git at begining of
> the bisection...
> 
> And no, I don't have right commits in the example file, I'd have to
> search for the right commits.
> 
> Best regards,
> 							Pavel
> 
> commit 75ad04e3fdf1d32a24e4203b628093560a2d7ac6
> Author: Pavel Machek <pavel@ucw.cz>
> Date:   Wed Mar 10 12:05:42 2021 +0100
> 
>     Add tool for detecting known-bad commits.
> 
> diff --git a/.known-bad b/.known-bad
> new file mode 100644
> index 000000000000..e86d6ffb260f
> --- /dev/null
> +++ b/.known-bad
> @@ -0,0 +1,4 @@
> +* 5.12-rc1 corrupts filesystems data using swap files
> +Bad: 3650b228f83adda7e5ee532e2b90429c03f7bafd
> +Fix: 3cea11cd5e3b00d91caf0b4730194039b45c5adf
> +
> diff --git a/tools/known-bad b/tools/known-bad
> new file mode 100755
> index 000000000000..36ef4f7033f4
> --- /dev/null
> +++ b/tools/known-bad
> @@ -0,0 +1,81 @@
> +#!/usr/bin/python3
> +import os
> +import sys
> +
> +def pcmd(c):
> +    return os.popen(c).readline()[:-1]
> +
> +def is_ancestor(this, anc):
> +    c1 = pcmd("git rev-parse %s" % this)
> +    c2 = pcmd("git rev-parse %s" % anc)
> +    if c1 == c2:
> +        return True
> +    r = os.system("git merge-base --is-ancestor %s %s" % (this, anc))
> +    if r == 0:
> +        return False
> +    if r == 256:
> +        return True
> +    print("Problem searching for ancestors:", r, this, anc)
> +    sys.exit(2)
> +
> +def known_bad(this, buggy, fix):
> +    if is_ancestor(this, fix):
> +        return False
> +    if is_ancestor(this, buggy):
> +        return True
> +    return False
> +
> +def test_suite():
> +    print("Anc false: ", is_ancestor("3650b228f83adda7e5ee532e2b90429c03f7b9ec", "3cea11cd5e3b00d91caf0b4730194039b45c5891"))
> +    print("Anc true: ", is_ancestor("3cea11cd5e3b00d91caf0b4730194039b45c5891", "3650b228f83adda7e5ee532e2b90429c03f7b9ec"))
> +    print("Anc same true: ", is_ancestor("3cea11cd5e3b00d91caf0b4730194039b45c5891", "3cea11cd5e3b00d91caf0b4730194039b45c5891"))
> +    #print("Anc non false: ", is_ancestor("3cea11cd5e3b00d91caf0b4730194039b45c5891", "3cea11cd5e3b00d91caf0b4730194039b45c5892"))
> +    
> +    # HEAD, v5.10-rc1, v5.10-rc2
> +    print("Expect false: ", known_bad("HEAD", "3650b228f83adda7e5ee532e2b90429c03f7b9ec", "3cea11cd5e3b00d91caf0b4730194039b45c5891"))
> +    # v5.10, v5.10-rc1, v5.10-rc2
> +    print("Expect false: ", known_bad("2c85ebc57b3e1817b6ce1a6b703928e113a90442", "3650b228f83adda7e5ee532e2b90429c03f7b9ec", "3cea11cd5e3b00d91caf0b4730194039b45c5891"))
> +    # v5.10-rc1, v5.10-rc1, v5.10-rc2
> +    print("Expect true: ", known_bad("3650b228f83adda7e5ee532e2b90429c03f7b9ec", "3650b228f83adda7e5ee532e2b90429c03f7b9ec", "3cea11cd5e3b00d91caf0b4730194039b45c5891"))
> +    print("Expect true: ", known_bad("3cea11cd5e3b00d91caf0b4730194039b45c5891^", "3650b228f83adda7e5ee532e2b90429c03f7b9ec", "3cea11cd5e3b00d91caf0b4730194039b45c5891"))
> +
> +def check_fixed(title, this, bad, is_fixed):
> +    v = True
> +    if v: print("Problem %s... %s %s", (title, this, bad))
> +    if is_fixed:
> +        if v: print("...is fixed")
> +        return
> +    if not is_ancestor(this, bad):
> +        if v: print("...is not present")
> +        return
> +    print("Problem %s is present in current tree", title)
> +
> +def check_file(this, f):
> +    title = None
> +    is_fixed = False
> +    for l in open(f).readlines():
> +        if l[-1] == "\n":
> +            l = l[:-1]
> +        if l[:2] == "* ":
> +            if title:
> +                check_fixed(title, this, bad, is_fixed)
> +            title = l
> +            is_fixed = False
> +            continue
> +        if l[:5] == "Bad: ":
> +            bad = l[5:]
> +            continue
> +        if l[:5] == "Fix: ":
> +            print("This is a fix: ",l[5:])
> +            if not is_fixed:
> +                if is_ancestor(this, l[5:]):
> +                    is_fixed = True
> +            continue
> +        if l[:1] == "#":
> +            continue
> +        print("Unrecognized line ", l)
> +
> +    check_fixed(title, this, bad, is_fixed)
> +            
> +test_suite()
> +check_file("HEAD", ".known-bad")
> 
> 



-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

           reply	other threads:[~2021-03-10 11:41 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20210310111039.GA7890@amd>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210310114053.GA9028@amd \
    --to=pavel@ucw.cz \
    --cc=jikos@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox