Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2005926imu; Thu, 24 Jan 2019 05:49:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN7/DMwoKg6dyJbTtHh3BzGKarqEdLToXDebEXCltr02zyj/rK4hZq4GiXOFts1k2yehXT1S X-Received: by 2002:a17:902:d01:: with SMTP id 1mr6713309plu.127.1548337750073; Thu, 24 Jan 2019 05:49:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548337750; cv=none; d=google.com; s=arc-20160816; b=RnUISy81HPKTv/If1zmemAoSbLPUlHkTQz80pJDvdo7Ys1AdgDPsqxhKPh1HBdQ65H 4xHPNYjqaxKCQ342qTf2zSrAnrJJ3NcMyVtX7vTJxuaU2EC5sfd5+bFByjwpn34MX3vX g2jCM3i6m0dUOw9M4ckN9YM8n05m7HHmap8EO61IjCS9BvZ49P320fkozU2Rftdlis9C FLWfXUwKJ5hLLaMBuTxcpDgSqN5Yydi5q0Db35YfbqCfpI+OKLv7CBsg0j2T45kpAlec g0kRgymLLgBSSjt7Ar8dY2zDe/X9OnOjix3eCYOdDtHt1uG5nJGB3e/wtCTaogkl9FtQ ICQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Nc4HdoDza9fmJvgOuCX0hf9NbkYW81xcyB/LVKlSf6g=; b=TD5z8njBJmpSQQUuwBWqiZuJUbCxIR3V0o084PE1sosuBLmHEj03BabTD6Ac5Yvr+y AWFCx280q09y4LvlgMo+IvDNOg1z9s9Od8QC/ol7YAMyDqSOJu9Mzq28iernTJjEnyQo SYi2Rc5n7T+dVPeZy18bc1wRDEwulMKX0kACfxSFFBpXP6xc0cqfFzYoyuAB4ruAs+vZ 7ZAaOkNlBkjsqX+sR4BIbRKuJyIUeux91MXSg3Be77+HVmV7jNjPqk122pzOJCrtTrbg d1rNwQU8b4LH8356JOYISNCDQuS/ZXrUcW3ALdeJfBxXLS7htaSQCb3XGZT8Vk111Msj C0yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b="fRprE/gK"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10si17912715pgi.562.2019.01.24.05.48.55; Thu, 24 Jan 2019 05:49:10 -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=@joelfernandes.org header.s=google header.b="fRprE/gK"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728152AbfAXNqt (ORCPT + 99 others); Thu, 24 Jan 2019 08:46:49 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:35776 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727522AbfAXNqt (ORCPT ); Thu, 24 Jan 2019 08:46:49 -0500 Received: by mail-qk1-f194.google.com with SMTP id w204so3230269qka.2 for ; Thu, 24 Jan 2019 05:46:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Nc4HdoDza9fmJvgOuCX0hf9NbkYW81xcyB/LVKlSf6g=; b=fRprE/gK6raxN94sfNaL/fwVOH1gmmU3cObXHZ4uPbq2fDIMp6+xijYerjbXCVKmaq I7jqYlDZQGoz3PHvFfq6GYWI60hsxr7QDphZqahmoAuxiG0typaYQx7rxrZ1vol0+h6Z MeKhdynucvIraruaKaobKiKRr9nfkv+TgQoNI= 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:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Nc4HdoDza9fmJvgOuCX0hf9NbkYW81xcyB/LVKlSf6g=; b=eZHwSaVZowCRG59xafQ33tz8npHjPNLSxC7Hd6P01xaAkIFbvMx53MZbBdB26ZwqVR iuiSAQ2sFjWlqvXBv+mM7YBzt5bh6zF8L+JZmUg4FLb7FVMq0TQ9vOX2J2ERz9cRkZRw RS78LeL1rKuuqXZD9Ggo3mF++5iOym02Bt6I0Irgbg6bApzK0KrjHBIXMjeGd17xs5NN nx/pJVLSQlBKHJnrEecQPTJo2xbT+aMF8TVEkL9Mh4p9Es6QbRcp7EHSLIlTXOYGOlYf w/QvgZBePik2rS5TPPvL0rqgxSHTn6xJVz5gJKvsVlA8WZpMTYqJEWnTa7lD4VAqsFOT +SQA== X-Gm-Message-State: AJcUukf4kSK7uk7lpTfZE9X2yoekHLVM+CxgsizxbeGBS/9EijVJ/R6f loDiSM+yUcv/Ms28KIrjueRDow== X-Received: by 2002:a37:dcc1:: with SMTP id v184mr5714294qki.212.1548337608061; Thu, 24 Jan 2019 05:46:48 -0800 (PST) Received: from localhost ([2620:0:1004:1100:cca9:fccc:8667:9bdc]) by smtp.gmail.com with ESMTPSA id 70sm47999337qkc.52.2019.01.24.05.46.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Jan 2019 05:46:46 -0800 (PST) Date: Thu, 24 Jan 2019 08:46:46 -0500 From: Joel Fernandes To: Tetsuo Handa Cc: Andrew Morton , Todd Kjos , syzbot+a76129f18c89f3e2ddd4@syzkaller.appspotmail.com, ak@linux.intel.com, Johannes Weiner , jack@suse.cz, jrdr.linux@gmail.com, LKML , linux-mm@kvack.org, mawilcox@microsoft.com, mgorman@techsingularity.net, syzkaller-bugs@googlegroups.com, Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Todd Kjos , Martijn Coenen , Greg Kroah-Hartman Subject: Re: possible deadlock in __do_page_fault Message-ID: <20190124134646.GA53008@google.com> References: <201901230201.x0N214eq043832@www262.sakura.ne.jp> <20190123155751.GA168927@google.com> <201901240152.x0O1qUUU069046@www262.sakura.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201901240152.x0O1qUUU069046@www262.sakura.ne.jp> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 24, 2019 at 10:52:30AM +0900, Tetsuo Handa wrote: > Joel Fernandes wrote: > > > Anyway, I need your checks regarding whether this approach is waiting for > > > completion at all locations which need to wait for completion. > > > > I think you are waiting in unwanted locations. The only location you need to > > wait in is ashmem_pin_unpin. > > > > So, to my eyes all that is needed to fix this bug is: > > > > 1. Delete the range from the ashmem_lru_list > > 2. Release the ashmem_mutex > > 3. fallocate the range. > > 4. Do the completion so that any waiting pin/unpin can proceed. > > > > Could you clarify why you feel you need to wait for completion at those other > > locations? > > Because I don't know how ashmem works. You sound like you're almost there though. > > Note that once a range is unpinned, it is open sesame and userspace cannot > > really expect consistent data from such range till it is pinned again. > > Then, I'm tempted to eliminate shrinker and LRU list (like a draft patch shown > below). I think this is not equivalent to current code because this shrinks > upon only range_alloc() time and I don't know whether it is OK to temporarily > release ashmem_mutex during range_alloc() at "Case #4" of ashmem_pin(), but > can't we go this direction? No, the point of the shrinker is to do a lazy free. We cannot free things during unpin since it can be pinned again and we need to find that range by going through the list. We also cannot get rid of any lists. Since if something is re-pinned, we need to find it and find out if it was purged. We also need the list for knowing what was unpinned so the shrinker works. By the way, all this may be going away quite soon (the whole driver) as I said, so just give it a little bit of time. I am happy to fix it soon if that's not the case (which I should know soon - like a couple of weeks) but I'd like to hold off till then. > By the way, why not to check range_alloc() failure before calling range_shrink() ? That would be a nice thing to do. Send a patch? thanks, - Joel