From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A31AC47409 for ; Tue, 14 Jan 2020 12:51:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1FDDA207E0 for ; Tue, 14 Jan 2020 12:51:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="H8ogLJT4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FDDA207E0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BE8458E0006; Tue, 14 Jan 2020 07:51:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B97298E0003; Tue, 14 Jan 2020 07:51:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5E818E0006; Tue, 14 Jan 2020 07:51:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 894628E0003 for ; Tue, 14 Jan 2020 07:51:15 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 31EF98248D7C for ; Tue, 14 Jan 2020 12:51:15 +0000 (UTC) X-FDA: 76376225310.09.cars47_27f749e640713 X-HE-Tag: cars47_27f749e640713 X-Filterd-Recvd-Size: 8043 Received: from mail-ot1-f68.google.com (mail-ot1-f68.google.com [209.85.210.68]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Jan 2020 12:51:14 +0000 (UTC) Received: by mail-ot1-f68.google.com with SMTP id r9so12437545otp.13 for ; Tue, 14 Jan 2020 04:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=W+Q9dUTyz/K5v7vEopmSX1VV9yqJ2uEeGg7eL1QYRZQ=; b=H8ogLJT4KSppaj5v6wRd8cfh2U1RCnvS92Q/nL6sSdEKzYtxsF2axbVarPObfNgzHB KV0k8nT+ZtNnpeuC2hbj+BgpTHl8vNoEEuBgtnhWDEHEu1SKsXP4JgGNA83bXKIUdB59 U6MboMqkQgaxVY84AdrSkvEsg1kBypKHrSFlv4QXpas64S1l9uxYKl9s0wRKtuuvoale I74WCTj3x2pCk479W3tLKKW3p5TfuhpDNJ8Mk0N82YX/wt8ZPwJcKIOeelgg9vihOEkx +YgeIrPu6icVC2A1thr//KRAx/mwDzZbANgDFTF4zW/rNZXmRtipvEziT7jz/spm41cN hVzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=W+Q9dUTyz/K5v7vEopmSX1VV9yqJ2uEeGg7eL1QYRZQ=; b=tFIIX3IYpM2hfH+7o7npOx7QDK/8Bc8lSCn/aZvECDz6W3DX90a86+KrUoA+sJJOJW mRdmrj4fmhIS5jp62UgaJxhet9W6by1qvpBXVvCy8DRyoX++2jHkNoHHsRMBawukmwQ7 tk+yg2DDcdmMF9I42sgYH6cHRJlBwTv9gz9DlP5tBJolVOt2xJY7/dCfJRk4kqGqqO47 swyDEJa++yXwa9eNYFviaJxIy3j19K56ktdtN/2/2GP8smCaisrYgtk5ogRYGixt1FDc lF/JnIcoGH/m+sDf981RdYU3T7OQT8k7QaKQs6/7/pW+HeORtVV7vdtmanhwxCF0OckD CWRQ== X-Gm-Message-State: APjAAAXnT1NrhW0IVIY06DT4mLPD7taoytOlXKN5KhJ1ePFxcuNbO8yX SCNQrfvfEsBD15Zv8bLMcCrNUbVyA5EOpECq9NCvsA== X-Google-Smtp-Source: APXvYqylNPgxJbf6k9XLiMRwipsE+quarg452EJku62GGvY7X+XxjzhfC+1cwAX2swh6rwtuKCrMh49rOEIbTPnfTtE= X-Received: by 2002:a9d:588c:: with SMTP id x12mr16233506otg.2.1579006273570; Tue, 14 Jan 2020 04:51:13 -0800 (PST) MIME-Version: 1.0 References: <53F6B915-AC53-41BB-BF32-33732515B3A0@lca.pw> In-Reply-To: <53F6B915-AC53-41BB-BF32-33732515B3A0@lca.pw> From: Marco Elver Date: Tue, 14 Jan 2020 13:51:01 +0100 Message-ID: Subject: Re: [PATCH v4 01/10] kcsan: Add Kernel Concurrency Sanitizer infrastructure To: Qian Cai Cc: LKMM Maintainers -- Akira Yokosawa , Alan Stern , Alexander Potapenko , Andrea Parri , Andrey Konovalov , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Boqun Feng , Borislav Petkov , Daniel Axtens , Daniel Lustig , Dave Hansen , David Howells , Dmitry Vyukov , "H. Peter Anvin" , Ingo Molnar , Jade Alglave , Joel Fernandes , Jonathan Corbet , Josh Poimboeuf , Luc Maranget , Mark Rutland , Nicholas Piggin , "Paul E. McKenney" , Peter Zijlstra , Thomas Gleixner , Will Deacon , Eric Dumazet , kasan-dev , linux-arch , "open list:DOCUMENTATION" , linux-efi@vger.kernel.org, Linux Kbuild mailing list , LKML , Linux Memory Management List , "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 14 Jan 2020 at 12:08, Qian Cai wrote: > > > > > On Jan 6, 2020, at 7:47 AM, Marco Elver wrote: > > > > Thanks, I'll look into KCSAN + lockdep compatibility. It's probably > > missing some KCSAN_SANITIZE :=3D n in some Makefile. > > Can I have a update on fixing this? It looks like more of a problem that = kcsan_setup_watchpoint() will disable IRQs and then dive into the page allo= cator where it would complain because it might sleep. KCSAN does *not* keep IRQs disabled (we have a clear irqsave / restore pair kcsan_setup_watchpoint). If you look closer at the warning you sent in this thread, the warning is not generated because IRQs are off when it wants to sleep, but rather because IRQs are enabled but IRQ tracing state is inconsistent: "DEBUG_LOCKS_WARN_ON(!current->hardirqs_enabled)" in lockdep checks that if IRQs are enabled, the trace state matches. These are only checked with LOCKDEP_DEBUG and TRACE_IRQFLAGS. In other words, IRQ trace flags got corrupted somewhere. AFAIK, this problem here is only relevant with TRACE_IRQFLAGS -- again, it is clear that IRQs are enabled but the IRQ tracing logic somehow ended up corrupting hardirqs_enabled (TRACE_IRQFLAGS). I believe this patch will take care of this issue: http://lkml.kernel.org/r/20200114124919.11891-1-elver@google.com Thanks, -- Marco > BTW, I saw Paul sent a pull request for 5.6 but it is ugly to have everyb= ody could trigger a deadlock (sleep function called in atomic context) like= this during boot once this hits the mainline not to mention about only rec= ently it is possible to test this feature (thanks to warning ratelimit) wit= h the existing debugging options because it was unable to boot due to the b= rokenness with debug_pagealloc as mentioned in this thread, so this does so= unds like it needs more soak time for the mainline to me. > > 0000000000000400 > [ 13.416814][ T1] Call Trace: > [ 13.416814][ T1] lock_is_held_type+0x66/0x160 > [ 13.416814][ T1] ___might_sleep+0xc1/0x1d0 > [ 13.416814][ T1] __might_sleep+0x5b/0xa0 > [ 13.416814][ T1] slab_pre_alloc_hook+0x7b/0xa0 > [ 13.416814][ T1] __kmalloc_node+0x60/0x300 > [ 13.416814 T1] ? alloc_cpumask_var_node+0x44/0x70 > [ 13.416814][ T1] ? topology_phys_to_logical_die+0x7e/0x180 > [ 13.416814][ T1] alloc_cpumask_var_node+0x44/0x70 > [ 13.416814][ T1] zalloc_cpumask_var+0x2a/0x40 > [ 13.416814][ T1] native_smp_prepare_cpus+0x246/0x425 > [ 13.416814][ T1] kernel_init_freeable+0x1b8/0x496 > [ 13.416814][ T1] ? rest_init+0x381/0x381 > [ 13.416814][ T1] kernel_init+0x18/0x17f > [ 13.416814][ T1] ? rest_init+0x381/0x381 > [ 13.416814][ T1] ret_from_fork+0x3a/0x50 > [ 13.416814][ T1] irq event stamp: 910 > [ 13.416814][ T1] hardirqs last enabled at (909): [] _raw_write_unlock_irqrestore+0x53/0x57 > [ 13.416814][ T1] hardirqs last disabled at (910): [] kcsan_setup_watchpoint+0x96/0x460 > [ 13.416814][ T1] softirqs last enabled at (0): [= ] copy_process+0x11fa/0x34f0 > [ 13.416814][ T1] softirqs last disabled at (0): [<0000000000000000>= ] 0x0 > [ 13.416814][ T1] ---[ end trace 7d1df66da055aa92 ]--- > [ 13.416814][ T1] possible reason: unannotated irqs-on. > [ 13.416814][ent stamp: 910 > [ 13.416814][ T1] hardirqs last enabled at (909): [] _raw_write_unlock_irqrestore+0x53/0x57 > [ 13.416814][ T1] hardirqs last disabled at (910): [] kcsan_setup_watchpoint+0x96/0x460 > [ 13.416814][ T1] softirqs last enabled at (0): [= ] copy_process+0x11fa/0x34f0 > [ 13.416814][ T1] softirqs last disabled at (0): [<0000000000000000>= ] 0x0