From patchwork Fri Jun 22 15:57:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10482641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8C3C160532 for ; Fri, 22 Jun 2018 15:57:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F53728D28 for ; Fri, 22 Jun 2018 15:57:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53A2128E5C; Fri, 22 Jun 2018 15:57:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA98C28E57 for ; Fri, 22 Jun 2018 15:57:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2E5B6B000A; Fri, 22 Jun 2018 11:57:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EB6F66B000C; Fri, 22 Jun 2018 11:57:21 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5B846B000D; Fri, 22 Jun 2018 11:57:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 748F86B000A for ; Fri, 22 Jun 2018 11:57:21 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id x14-v6so595312edr.16 for ; Fri, 22 Jun 2018 08:57:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:date:from:to :cc:subject:message-id:references:mime-version:content-disposition :in-reply-to:user-agent; bh=Auj+3YLY+Trb+Gc5or01MwVuf7HaxJTPfUkQcwUeUHw=; b=UNpzy80EMg/+GDbAzc5mZ8XimSbdB1vdPqGryHQWF+//B9SJhyRCVtWjIJoIjGT3Hv AtQm7Zxt/+/lrdBLMyBfL8iEgQKw2MTv+2UUmEjiAqiWCyoEhpYqhh1otCAVTkOmXnbB mPll54+pnfxh/Tk/PYkcUtOXkZRoHAaC3Q4NMzBmHagVjAYIYXec4yL/rhIKC2rcMX69 JzutZBeoZXPg36DuEGrtBiwMtdFiBaTo11y20qWnSg1MRdcY0TVxVpIUySw2O/+fkgnw p/gCz8Qt7wCIMU5NUTbxtSmz3gsgKHCUDlfXUpej5fJorUojUnOgVMV5Oevj/CWLzG6I 0bAQ== X-Original-Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning mhocko@kernel.org does not designate 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: APt69E3mxTGpPUoO3MaIrpuLZ8e1XWCrly9SXeU53/dIEDTOnW1iWrtw uDXqx4qkdkOdfGskxkmfT+w6yhXRKX4P+CLwnzwVxeIoCf4m4yVNTXlmed/2PdpZUGykWIgKioB qSIsh/vBNxifyQchbn2v+WIxgyWCdayEHgk6/AJO0auUbCK+wJHnKxm+hCYnaw38= X-Received: by 2002:a50:b8a4:: with SMTP id l33-v6mr2312487ede.273.1529683041021; Fri, 22 Jun 2018 08:57:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKWxGTMACMerqsZUi9jylMNWA/ZCLLrNvjlJYOL+pti9rRDg0aoEy0ZXD+7/wVF5J0NueHI X-Received: by 2002:a50:b8a4:: with SMTP id l33-v6mr2312431ede.273.1529683040227; Fri, 22 Jun 2018 08:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529683040; cv=none; d=google.com; s=arc-20160816; b=zptis4s8nItRERwAKDXU150vZheVhaV+BJLxstFmpoK+hFTWlqKmHJvLnra9JW7KTh YvAeWkPGdaHS+9ZCtX0BOzsn+YeBhxkHX4WrlnZFSInK7QXfTQf0qbEadSmde3JyTW5R kT7hSZAdqJ6nneTh5nl9jfgDvdsI/RjvD0smpoTgvjdSdrLEEq8qxxykJ6E3LVPYb6J6 79v9sgotE9IDWiLgVXoDP8oxYfPODrFi0LGCVLmHNJIzOnJFn5EKYFpO8YO2TKfcJbDw FTyD3GKgp24PCJH6H4uQ8fcQT5KkZa8Aj8OxJB2nwUhs/CEg0T9nPI6uSNPy09/8YnG/ tgUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:arc-authentication-results; bh=Auj+3YLY+Trb+Gc5or01MwVuf7HaxJTPfUkQcwUeUHw=; b=NvyqDO9n0YHZ3uMEdRqNylJ7xvhZS8We5vYPBsN1Fl0mDkH7j3Oaat82Q8JRKmIZZs Lje9kwjyfGKpQZVy0n2uWsxZrwUxPGW/jVle50y64jrpP85VynFfYW2kudNoiaWXsOrY Qks5Bo8UPPavz1dxlxykntHy1M9CT+uvzuJ92LxJivKvYY+nmh4C+4ItAbrxNZil1swB HRrSYTWiIxQydxnW6wMBZXv2ZDSCOSolL7Mi1D3QyfrhPXqrkuU2Y1U4SX4IV6fdJVWG L9KofWWu1x8N8OR6cEQ20Ji68YcYE5t9AQbtxL+BYVpH5l7tP5m/GDHLxHg0CdKwhkbx e3UA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning mhocko@kernel.org does not designate 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id m3-v6si3886860ede.147.2018.06.22.08.57.19 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Jun 2018 08:57:20 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning mhocko@kernel.org does not designate 195.135.220.15 as permitted sender) client-ip=195.135.220.15; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning mhocko@kernel.org does not designate 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2DA27AD5C; Fri, 22 Jun 2018 15:57:19 +0000 (UTC) Date: Fri, 22 Jun 2018 17:57:16 +0200 From: Michal Hocko To: Chris Wilson Cc: LKML , Michal Hocko =?utf-8?B?PG1ob2Nrb0BzdXNlLmNvbT4sIGt2bUB2Z2VyLmtlcm5l?= =?utf-8?B?bC5vcmcsICAiIFJhZGltIEtyxI1tw6HFmSA8cmtyY21hckByZWRoYXQuY29t?= =?utf-8?B?Piw=?= David Airlie , Sudeep Dutt , dri-devel@lists.freedesktop.org, linux-mm@kvack.org, Andrea Arcangeli , "David (ChunMing) Zhou" , Dimitri Sivanich , linux-rdma@vger.kernel.org, amd-gfx@lists.freedesktop.org, Jason Gunthorpe , Doug Ledford , David Rientjes , xen-devel@lists.xenproject.org, intel-gfx@lists.freedesktop.org, =?iso-8859-1?B?IiBK6XL0bWU=?= Glisse , Rodrigo@kvack.org, Vivi@kvack.org, Boris@kvack.org, Ostrovsky@kvack.org, Juergen@kvack.org, Gross@kvack.org, Mike@kvack.org, Marciniszyn@kvack.org, Dennis@kvack.org, Dalessandro@kvack.org, Ashutosh@kvack.org, Dixit@kvack.org, Alex@kvack.org, Deucher@kvack.org, Paolo@kvack.org, Bonzini@kvack.org Subject: Re: [Intel-gfx] [RFC PATCH] mm, oom: distinguish blockable mode for mmu notifiers Message-ID: <20180622155716.GE10465@dhcp22.suse.cz> References: <20180622150242.16558-1-mhocko@kernel.org> <152968180950.11773.3374981930722769733@mail.alporthouse.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <152968180950.11773.3374981930722769733@mail.alporthouse.com> User-Agent: Mutt/1.9.5 (2018-04-13) 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: X-Virus-Scanned: ClamAV using ClamSMTP On Fri 22-06-18 16:36:49, Chris Wilson wrote: > Quoting Michal Hocko (2018-06-22 16:02:42) > > Hi, > > this is an RFC and not tested at all. I am not very familiar with the > > mmu notifiers semantics very much so this is a crude attempt to achieve > > what I need basically. It might be completely wrong but I would like > > to discuss what would be a better way if that is the case. > > > > get_maintainers gave me quite large list of people to CC so I had to trim > > it down. If you think I have forgot somebody, please let me know > > > diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c > > index 854bd51b9478..5285df9331fa 100644 > > --- a/drivers/gpu/drm/i915/i915_gem_userptr.c > > +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c > > @@ -112,10 +112,11 @@ static void del_object(struct i915_mmu_object *mo) > > mo->attached = false; > > } > > > > -static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, > > +static int i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, > > struct mm_struct *mm, > > unsigned long start, > > - unsigned long end) > > + unsigned long end, > > + bool blockable) > > { > > struct i915_mmu_notifier *mn = > > container_of(_mn, struct i915_mmu_notifier, mn); > > @@ -124,7 +125,7 @@ static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, > > LIST_HEAD(cancelled); > > > > if (RB_EMPTY_ROOT(&mn->objects.rb_root)) > > - return; > > + return 0; > > The principle wait here is for the HW (even after fixing all the locks > to be not so coarse, we still have to wait for the HW to finish its > access). Is this wait bound or it can take basically arbitrary amount of time? > The first pass would be then to not do anything here if > !blockable. something like this? (incremental diff) diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c index 5285df9331fa..e9ed0d2cfabc 100644 --- a/drivers/gpu/drm/i915/i915_gem_userptr.c +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c @@ -122,6 +122,7 @@ static int i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, container_of(_mn, struct i915_mmu_notifier, mn); struct i915_mmu_object *mo; struct interval_tree_node *it; + int ret = 0; LIST_HEAD(cancelled); if (RB_EMPTY_ROOT(&mn->objects.rb_root)) @@ -133,6 +134,10 @@ static int i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, spin_lock(&mn->lock); it = interval_tree_iter_first(&mn->objects, start, end); while (it) { + if (!blockable) { + ret = -EAGAIN; + goto out_unlock; + } /* The mmu_object is released late when destroying the * GEM object so it is entirely possible to gain a * reference on an object in the process of being freed @@ -154,8 +159,10 @@ static int i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, spin_unlock(&mn->lock); /* TODO: can we skip waiting here? */ - if (!list_empty(&cancelled) && blockable) + if (!list_empty(&cancelled)) flush_workqueue(mn->wq); + + return ret; } static const struct mmu_notifier_ops i915_gem_userptr_notifier = {