Received: by 10.223.164.221 with SMTP id h29csp3068001wrb; Fri, 3 Nov 2017 00:47:36 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Rl3vN3rRxig8eeWh8cTO/wGwhb6oonLhcnF0ZcFgt1WdKOO2FDYV4ReeoFcWMq6F6/HHM0 X-Received: by 10.101.64.9 with SMTP id f9mr6425667pgp.114.1509695256884; Fri, 03 Nov 2017 00:47:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509695256; cv=none; d=google.com; s=arc-20160816; b=cIaIGVnhdC2y4oXn2ijQGab+CuUaA+nAonx/VaHHCksoO+6vGEAeYnirKUrmlGdrVK FoJoU8F5DULROyY9QKqy2ubvI8jlvIA0j52o4PlH1kGU3G76uy9hcnRwqrZF0qNPNRaQ Tew9Lke6S8JW9fRYg/IWBmTMRozDSGd8DB5MYinHzyKGlD+2rNK38SxPe8ManAGJHs+B xG6sAjVyqQoMDjLPXqNEyiiVd7IUE8LpNtlUUhn04mhCZFYAJA3Dc41D6Gm94rbvzRbj eIuya5Zv3SJdr2CVF5FLDy4T24KyDlkSrsKeXt0J9vHvb0xwbmXBldHeRAsLdgHq7hTT 8aPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=MPbv53ytmk1fkY+E7faiFDuFu607cAft1YymIzKgGSc=; b=p4YPEU9RSM6wvQI7wo5OaOqmUtjIjVOE2kLgMc7pf6zwRG47RVqRv610UVWY8+iTQQ zuzg+4H9w0z8LVMv0rvzNE4sqBgC0G32MsBJTXXno2mVUf3lJSRm/3D6KbwduEz7238a 5fmKPH+sLuWID+TZ8tyoWQadg23nkzLlWEoo740X6LzeKHYPe8vACy6cIM5xYDLeDCzV GYyZ4isuasFFUH5lqr6y0PrXsNgq8iJDkyRqX7iEZXiNgclIoEOrJKE1Emb5mVr7H5mX WPX++KonRMuqgGAZKQqXO6c2h7GiU9ijuQbAgqNMH2zz76jPaX+wj5XN3N+t/pVzB+Iw fWuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jkQ5u4z9; 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 32si4233542pls.667.2017.11.03.00.47.23; Fri, 03 Nov 2017 00:47:36 -0700 (PDT) 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=jkQ5u4z9; 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 S1754838AbdKCHqd (ORCPT + 96 others); Fri, 3 Nov 2017 03:46:33 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:49107 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751370AbdKCHqc (ORCPT ); Fri, 3 Nov 2017 03:46:32 -0400 Received: by mail-oi0-f67.google.com with SMTP id m198so1511026oig.5 for ; Fri, 03 Nov 2017 00:46:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=MPbv53ytmk1fkY+E7faiFDuFu607cAft1YymIzKgGSc=; b=jkQ5u4z9K8OouiZa45SbBfVw9ZRcE6VJtzFDwfzx9xmp79BpWFwhszkMMmBxkfKYJZ bXaXjStwQ6yq0ZVxsSoINWyNOnoGTVLatYAwdHVbeUB9ElzXZCX4mEilYSEVBolIwKsn XpsjJfZxSagruuBPMudZTsT5EsE7ZrMQ+Qps7CMEvYoQG2S8E9rQEiZhnOqHG07QUEHr bKd64oCEsMSriF2Zv4xfEwjZAc8sO0AOx28Wg6MGw8TuRFZgL6/KKY48z1Qeuqs22jxF 3T+vklOrn6wZZtBOAgFaz8COtE+rYAx8Za2WFGjeXAvm/aHSlZF1f8bPfvQY9MR5h1/6 qh6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=MPbv53ytmk1fkY+E7faiFDuFu607cAft1YymIzKgGSc=; b=SycHfy0E7tqAlT8Owgzdwg0XY+EA2B9yyDpdM0pE8pEL3tOMrrgA/OWb4aWXEtcNEC 2rWc+JITJZObt+0DWeEzvHxF7AruXFnJk671MU7/fuuTmC4Zq7tymLTjAqxb78apkBEg 3XI3wZfKvGpFvqg7OigwBEA2HdzPk0N8kGlq0CGurAqycBcGefg3sJdqhMSdrCC8Gp/j QfInWfSEilBRQuloR8XUbIBwNQYKup7LhsDorq2f8fK3N7rt+sXS0feK/e2gNhkkm4GZ 82/bC0+5CpJIGTYBWNH7NdKTvs/iz5GSkznufmxDE9w4ThXvJJFf/YUmUnmwxxpcX2FT UnSA== X-Gm-Message-State: AMCzsaVPbS3FDXDt+wukqkgJthREF5nbcT/7VUJB1WBhnlfwvoSCrr6h vWUWOlB1NQqzXe8CfiJjXPthbQ== X-Received: by 10.202.166.18 with SMTP id p18mr3704288oie.192.1509695191182; Fri, 03 Nov 2017 00:46:31 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id o58sm2616196otb.2.2017.11.03.00.46.29 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Nov 2017 00:46:30 -0700 (PDT) Date: Fri, 3 Nov 2017 00:46:18 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Michal Hocko cc: linux-mm@kvack.org, Peter Zijlstra , Thomas Gleixner , Johannes Weiner , Mel Gorman , Tejun Heo , LKML , Michal Hocko , David Herrmann , Hugh Dickins Subject: Re: [PATCH 1/2] shmem: drop lru_add_drain_all from shmem_wait_for_pins In-Reply-To: <20171102093613.3616-2-mhocko@kernel.org> Message-ID: References: <20171102093613.3616-1-mhocko@kernel.org> <20171102093613.3616-2-mhocko@kernel.org> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2 Nov 2017, Michal Hocko wrote: > From: Michal Hocko > > syzkaller has reported the following lockdep splat > ====================================================== > WARNING: possible circular locking dependency detected > 4.13.0-next-20170911+ #19 Not tainted > ------------------------------------------------------ > syz-executor5/6914 is trying to acquire lock: > (cpu_hotplug_lock.rw_sem){++++}, at: [] get_online_cpus include/linux/cpu.h:126 [inline] > (cpu_hotplug_lock.rw_sem){++++}, at: [] lru_add_drain_all+0xe/0x20 mm/swap.c:729 > > but task is already holding lock: > (&sb->s_type->i_mutex_key#9){++++}, at: [] inode_lock include/linux/fs.h:712 [inline] > (&sb->s_type->i_mutex_key#9){++++}, at: [] shmem_add_seals+0x197/0x1060 mm/shmem.c:2768 > > more details [1] and dependencies explained [2]. The problem seems to be > the usage of lru_add_drain_all from shmem_wait_for_pins. While the lock > dependency is subtle as hell and we might want to make lru_add_drain_all > less dependent on the hotplug locks the usage of lru_add_drain_all seems > dubious here. The whole function cares only about radix tree tags, page > count and page mapcount. None of those are touched from the draining > context. So it doesn't make much sense to drain pcp caches. Moreover > this looks like a wrong thing to do because it basically induces > unpredictable latency to the call because draining is not for free > (especially on larger machines with many cpus). > > Let's simply drop the call to lru_add_drain_all to address both issues. > > [1] http://lkml.kernel.org/r/089e0825eec8955c1f055c83d476@google.com > [2] http://lkml.kernel.org/r/http://lkml.kernel.org/r/20171030151009.ip4k7nwan7muouca@hirez.programming.kicks-ass.net > > Cc: David Herrmann > Cc: Hugh Dickins > Signed-off-by: Michal Hocko NAK. shmem_wait_for_pins() is waiting for temporary pins on the pages to go away, and using lru_add_drain_all() in the usual way, to lower the refcount of pages temporarily pinned in a pagevec somewhere. Page count is touched by draining pagevecs: I'm surprised to see you say that it isn't - or have pagevec page references been eliminated by a recent commit that I missed? I hope your other patch, or another cpu hotplug locking fix, can deal with this. If not, I might be forced to spend some hours understanding the story that lockdep is telling us there - you're probably way ahead of me on that. Maybe a separate inode lock initializer for shmem inodes would offer a way out. Hugh > --- > mm/shmem.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/mm/shmem.c b/mm/shmem.c > index d6947d21f66c..e784f311d4ed 100644 > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -2668,9 +2668,7 @@ static int shmem_wait_for_pins(struct address_space *mapping) > if (!radix_tree_tagged(&mapping->page_tree, SHMEM_TAG_PINNED)) > break; > > - if (!scan) > - lru_add_drain_all(); > - else if (schedule_timeout_killable((HZ << scan) / 200)) > + if (scan && schedule_timeout_killable((HZ << scan) / 200)) > scan = LAST_SCAN; > > start = 0; > -- > 2.14.2 > > From 1582946571328910726@xxx Thu Nov 02 09:38:09 +0000 2017 X-GM-THRID: 1582946571328910726 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread