Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1096881ybm; Tue, 21 May 2019 08:35:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4jmg315UbXIfZuUKt+/8NEy9OiH6HH4mPlDPLw+9EXG60bwQMigJJPJXpSBzqLmbaPBjs X-Received: by 2002:a63:d615:: with SMTP id q21mr81751952pgg.401.1558452905101; Tue, 21 May 2019 08:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558452905; cv=none; d=google.com; s=arc-20160816; b=WWPGdt2vPHhWbWKghErIHsgXOOSWhMM0xfkwds3lQ8IW1Vq327vFV1QGPszG2A/vgk kzqrx56Xli1GThKhCH0TuZjqP1rSEZC7PKyD3kfkUaEge6w+KeltIS9yfcB5AO1Cr2Aw gO8dixfmFL1l7mWLqQaK+TTlddcAKojUw8QaSwnnVFyAnqX/wf4OY60ECVHpl+2IJgUg bp2hnMBnarwvctPmf/2vz4BtYxB8TEFTdSsxI5J4NtSgVDleeDvy74iOJ9lsNYrPX31Z Ey1cj2ul9Wj3bBLe964NrSckaccjLrnLHKkolruPuOg7zhK3IPMzGF0G7H2QKWeBWtUX /rrA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=qvYnwZC6jFUuIM+ALwxc+F2HuuuthAmCvbW66l4fovk=; b=LIuC9AOEjFjSMjNYGqrm5GbRkEGWOSsluEruvlQHbnEAGNYh+ssAlCROQ5+WPwuyi/ sLxmwbKRn6565tq0WT0NxWjZFea2IvOoMZXHaSFl0GwOoAe4rn7UuGPIaWCvsCizHfCU LcjHfyUFc/oodvDJhWjqyJ/HISYjDcsMZq5Iks+ljLy4rZwMKUq/9X/SpIkEHa06xpeT h1BZWnCJeCS9vTCedA3rOo/TY/SgC7p0uWwPIW6NYSjVw7V/sa/AWgrqpZoeYMQgU/xd SHY6yfG2LLQwrpaZbDZzBRpKAh20/aL35d90ZOGC/Dxs0MPgHqWcqtHw8g28c5fUbp+A KiGA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v14si22863299pfa.252.2019.05.21.08.34.49; Tue, 21 May 2019 08:35:05 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728695AbfEUPcN (ORCPT + 99 others); Tue, 21 May 2019 11:32:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60358 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728137AbfEUPcM (ORCPT ); Tue, 21 May 2019 11:32:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18E00883D7; Tue, 21 May 2019 15:32:05 +0000 (UTC) Received: from redhat.com (unknown [10.20.6.178]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1505C5378A; Tue, 21 May 2019 15:32:02 +0000 (UTC) Date: Tue, 21 May 2019 11:32:00 -0400 From: Jerome Glisse To: Daniel Vetter Cc: DRI Development , Intel Graphics Development , LKML , Linux MM , Andrew Morton , Michal Hocko , David Rientjes , Christian =?iso-8859-1?Q?K=F6nig?= , Daniel Vetter Subject: Re: [PATCH 3/4] mm, notifier: Catch sleeping/blocking for !blockable Message-ID: <20190521153200.GB3836@redhat.com> References: <20190520213945.17046-1-daniel.vetter@ffwll.ch> <20190520213945.17046-3-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190520213945.17046-3-daniel.vetter@ffwll.ch> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 21 May 2019 15:32:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 20, 2019 at 11:39:44PM +0200, Daniel Vetter wrote: > We need to make sure implementations don't cheat and don't have a > possible schedule/blocking point deeply burried where review can't > catch it. > > I'm not sure whether this is the best way to make sure all the > might_sleep() callsites trigger, and it's a bit ugly in the code flow. > But it gets the job done. > > Inspired by an i915 patch series which did exactly that, because the > rules haven't been entirely clear to us. > > v2: Use the shiny new non_block_start/end annotations instead of > abusing preempt_disable/enable. > > v3: Rebase on top of Glisse's arg rework. > > v4: Rebase on top of more Glisse rework. > > Cc: Andrew Morton > Cc: Michal Hocko > Cc: David Rientjes > Cc: "Christian K?nig" > Cc: Daniel Vetter > Cc: "J?r?me Glisse" > Cc: linux-mm@kvack.org > Reviewed-by: Christian K?nig > Signed-off-by: Daniel Vetter > --- > mm/mmu_notifier.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c > index c05e406a7cd7..a09e737711d5 100644 > --- a/mm/mmu_notifier.c > +++ b/mm/mmu_notifier.c > @@ -176,7 +176,13 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) > id = srcu_read_lock(&srcu); > hlist_for_each_entry_rcu(mn, &range->mm->mmu_notifier_mm->list, hlist) { > if (mn->ops->invalidate_range_start) { > - int _ret = mn->ops->invalidate_range_start(mn, range); > + int _ret; > + > + if (!mmu_notifier_range_blockable(range)) > + non_block_start(); > + _ret = mn->ops->invalidate_range_start(mn, range); > + if (!mmu_notifier_range_blockable(range)) > + non_block_end(); This is a taste thing so feel free to ignore it as maybe other will dislike more what i prefer: + if (!mmu_notifier_range_blockable(range)) { + non_block_start(); + _ret = mn->ops->invalidate_range_start(mn, range); + non_block_end(); + } else + _ret = mn->ops->invalidate_range_start(mn, range); If only we had predicate on CPU like on GPU :) In any case: Reviewed-by: J?r?me Glisse > if (_ret) { > pr_info("%pS callback failed with %d in %sblockable context.\n", > mn->ops->invalidate_range_start, _ret, > -- > 2.20.1 >