Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8728imu; Wed, 2 Jan 2019 12:56:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN6wjxkWV55AC3x0VIxBGBokMHI+Ir66Ls8OyvyD9vrgTz6L9NqP9T54HFv2c9NFGoaQXM8y X-Received: by 2002:a63:f65:: with SMTP id 37mr14703387pgp.238.1546462565485; Wed, 02 Jan 2019 12:56:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546462565; cv=none; d=google.com; s=arc-20160816; b=O9GlLelf5t1vshzVR2h89diRZNDhM6QlPZdpySP7FcMEeQshqjbQbK9IO3rK0qgpxL ydLIUQrtby5g6secZZuYIu/dUu3pnNKk0MBvDs9Vri7UPHdaZErdWFXX2kpjYZUmpXht 3bemAwu1sxjPaqdJpE+2b1Tf3y6jfi3r/SrPqb5m+12SkZPFJ+tnjxrwrCSX6NJTc599 lXrss+a5JMI6nLYC6m05EBfV3VhIWB5yIsSCve+SflTL25Rp7sZWSWzMq3pNUWaHwOF9 PZFOqgssULj1K5PKSvM52G/mKyzXp/XDJaAGU1e3meigyk7+hGCBzUrKGnQKXd0GgVfj vLDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=D9SJWAAY9/QXJCI4Fl7OpN64fV1E5Pup0uWqSCVW0E0=; b=Ey7Th2iug9zaBepEn5LtrxL2C/B3PLQinnqF64F3nRgtEBsYWsSrHor78Ob6X+8myH 7TuPZ/TkyQ/oyTdPuqjVRjmM7dQqnWjCunPlgdbncAyYw53xEhg4JbxErKgIG4EDJSQU vQxBm9E5FWV5YxjvszYuetUPz/D9YhWgotB+sepI4p6KPy/OW6RYaXjxXlhkSpQF5v87 4HGb25s++l+l1SlxcoI1cRJ/b+mBVlrR4CSUTjwVxIiWjcYAmcGy9N3fVh9J4S84+OtJ MXosTZBEsKpX9LjbR+pRitz4Pt75QTd1xJgoaNgimlmNpQLBPTyBo36v9KLqyIhyYZHn 3nOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=O0Z9W7W+; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si49246705pgj.542.2019.01.02.12.55.46; Wed, 02 Jan 2019 12:56:05 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=O0Z9W7W+; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728144AbfABS35 (ORCPT + 99 others); Wed, 2 Jan 2019 13:29:57 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:52773 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbfABS34 (ORCPT ); Wed, 2 Jan 2019 13:29:56 -0500 Received: by mail-it1-f194.google.com with SMTP id g76so42089102itg.2 for ; Wed, 02 Jan 2019 10:29:55 -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; bh=D9SJWAAY9/QXJCI4Fl7OpN64fV1E5Pup0uWqSCVW0E0=; b=O0Z9W7W+4aozqnfp0HoWpaEDW+EyNHpaTcHcnBiPZ4xczP7WE4sku38nwwbO8tmvr4 iLiy7XU3Fsoh8Qm+fNc2+RZxhv1VryvhrfK8Ss2TEETv8SM+PrL63qGabIFWE4jVX3DG 79sCrtVBHeu9MFs8Or6Y2gL4PE07Uc3lpJEfEo3OuFMknVnTz4WEhSHj9OQrFKOtVRSp ABVNd04RTDQ+S/H1L/rFr3bV9L2/QC64MWgwyDkpyPuPaptZft4EGlNFtNA1JTE1b/7R Qq9a3TQQK1ZiZEVgSt1NRe+6a1oeQDxgkBUoex3ORftsLmKrp9k1o/TI2sXfWgk614yc x9IQ== 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; bh=D9SJWAAY9/QXJCI4Fl7OpN64fV1E5Pup0uWqSCVW0E0=; b=PwqHwqBE3jKvR0GMu1tO8zoYjVx836/aBt38tYzHs0cds3JomNLEUVboC8MZo0Y4D1 0yxjKhZkfQ5GdM09HXC99JWNmnRExR4olG2gYIBxz7cXdQbgvAFn0SVpzuiISlqyjwL+ ohuIWBt/vb3JUHEdVb8lXeK29YAumeEI9I6OkLunvPq+jVmynBScgfrbPsSaNoGw7B0U O+MOh3dB/LyW5w1ME3lBad3HdplsmXgttBnVETkKnkU1fc8ZyI28Xtpf/on8PI/NablR wJFFHIFhCb3A1faIyqX3G+tQuyXLvLhx4YlfdfhgricxzVxDWcUonobyGo2rv11EGGVd N/bQ== X-Gm-Message-State: AA+aEWbu9/ZQP6seKHquVBE4gWtHfqmO5HU1A3wlyvruFKxnMnrjLCpU lG08Qtl4bnNp3PTvAJAOWrC12QV44QFCWTprHDNEvw== X-Received: by 2002:a02:ac8c:: with SMTP id x12mr27388743jan.72.1546453795043; Wed, 02 Jan 2019 10:29:55 -0800 (PST) MIME-Version: 1.0 References: <000000000000f67ca2057e75bec3@google.com> <1194004c-f176-6253-a5fd-682472dccacc@suse.cz> <20190102180611.GE31517@techsingularity.net> In-Reply-To: <20190102180611.GE31517@techsingularity.net> From: Dmitry Vyukov Date: Wed, 2 Jan 2019 19:29:43 +0100 Message-ID: Subject: Re: possible deadlock in __wake_up_common_lock To: Mel Gorman Cc: Vlastimil Babka , syzbot , Andrea Arcangeli , Andrew Morton , "Kirill A. Shutemov" , LKML , Linux-MM , linux@dominikbrodowski.net, Michal Hocko , David Rientjes , syzkaller-bugs , xieyisheng1@huawei.com, zhong jiang , Peter Zijlstra , Ingo Molnar Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 2, 2019 at 7:06 PM Mel Gorman wrote: > > On Wed, Jan 02, 2019 at 01:51:01PM +0100, Vlastimil Babka wrote: > > On 1/2/19 9:51 AM, syzbot wrote: > > > Hello, > > > > > > syzbot found the following crash on: > > > > > > HEAD commit: f346b0becb1b Merge branch 'akpm' (patches from Andrew) > > > git tree: upstream > > > console output: https://syzkaller.appspot.com/x/log.txt?x=1510cefd400000 > > > kernel config: https://syzkaller.appspot.com/x/.config?x=c255c77ba370fe7c > > > dashboard link: https://syzkaller.appspot.com/bug?extid=93d94a001cfbce9e60e1 > > > compiler: gcc (GCC) 8.0.1 20180413 (experimental) > > > userspace arch: i386 > > > > > > Unfortunately, I don't have any reproducer for this crash yet. > > > > > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > > > Reported-by: syzbot+93d94a001cfbce9e60e1@syzkaller.appspotmail.com > > > > > > > > > ====================================================== > > > WARNING: possible circular locking dependency detected > > > 4.20.0+ #297 Not tainted > > > ------------------------------------------------------ > > > syz-executor0/8529 is trying to acquire lock: > > > 000000005e7fb829 (&pgdat->kswapd_wait){....}, at: > > > __wake_up_common_lock+0x19e/0x330 kernel/sched/wait.c:120 > > > > From the backtrace at the end of report I see it's coming from > > > > > wakeup_kswapd+0x5f0/0x930 mm/vmscan.c:3982 > > > steal_suitable_fallback+0x538/0x830 mm/page_alloc.c:2217 > > > > This wakeup_kswapd is new due to Mel's 1c30844d2dfe ("mm: reclaim small > > amounts of memory when an external fragmentation event occurs") so CC Mel. > > > > New year new bugs :( Old too :( https://syzkaller.appspot.com/#upstream-open > > > but task is already holding lock: > > > 000000009bb7bae0 (&(&zone->lock)->rlock){-.-.}, at: spin_lock > > > include/linux/spinlock.h:329 [inline] > > > 000000009bb7bae0 (&(&zone->lock)->rlock){-.-.}, at: rmqueue_bulk > > > mm/page_alloc.c:2548 [inline] > > > 000000009bb7bae0 (&(&zone->lock)->rlock){-.-.}, at: __rmqueue_pcplist > > > mm/page_alloc.c:3021 [inline] > > > 000000009bb7bae0 (&(&zone->lock)->rlock){-.-.}, at: rmqueue_pcplist > > > mm/page_alloc.c:3050 [inline] > > > 000000009bb7bae0 (&(&zone->lock)->rlock){-.-.}, at: rmqueue > > > mm/page_alloc.c:3072 [inline] > > > 000000009bb7bae0 (&(&zone->lock)->rlock){-.-.}, at: > > > get_page_from_freelist+0x1bae/0x52a0 mm/page_alloc.c:3491 > > > > > > which lock already depends on the new lock. > > > > However, I don't understand why lockdep thinks it's a problem. IIRC it > > doesn't like that we are locking pgdat->kswapd_wait.lock while holding > > zone->lock. That means it has learned that the opposite order also > > exists, e.g. somebody would take zone->lock while manipulating the wait > > queue? I don't see where but I admit I'm not good at reading lockdep > > splats, so CCing Peterz and Ingo as well. Keeping rest of mail for > > reference. > > > > I'm not sure I'm reading the output correctly because I'm having trouble > seeing the exact pattern that allows lockdep to conclude the lock ordering > is problematic. > > I think it's hungup on the fact that mod_timer can allocate debug > objects for KASAN and somehow concludes that the waking of kswapd is > problematic because potentially a lock ordering exists that would trip. > I don't see how it's actually possible though due to either a lack of > imagination or maybe lockdep is being cautious as something could change > in the future that allows the lockup. > > There are a few options I guess in order of preference. > > 1. Drop zone->lock for the call. It's not necessarily to keep track of > the IRQ flags as callers into that path already do things like treat > IRQ disabling and the spin lock separately. > > 2. Use another alloc_flag in steal_suitable_fallback that is set when a > wakeup is required but do the actual wakeup in rmqueue() after the > zone locks are dropped and the allocation request is completed > > 3. Always wakeup kswapd if watermarks are boosted. I like this the least > because it means doing wakeups that are unrelated to fragmentation > that occurred in the current context. > > Any particular preference? > > While I recognise there is no test case available, how often does this > trigger in syzbot as it would be nice to have some confirmation any > patch is really fixing the problem. This info is always available over the "dashboard link" in the report: https://syzkaller.appspot.com/bug?extid=93d94a001cfbce9e60e1 In this case it's 1. I don't know why. Lock inversions are easier to trigger in some sense as information accumulates globally. Maybe one of these stacks is hard to trigger, or maybe all these stacks are rarely triggered on one machine. While the info accumulates globally, non of the machines are actually run for any prolonged time: they all crash right away on hundreds of known bugs. So good that Qian can reproduce this.