Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1823320imm; Thu, 23 Aug 2018 09:18:22 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyvDdp39mLFNPEOaoafA/zkGqtfsBSZPwOeSZdJ8UKL7fnCDeAaZr5ZG8fWMJW2dyQbrxkM X-Received: by 2002:a63:ea0c:: with SMTP id c12-v6mr56476619pgi.158.1535041102245; Thu, 23 Aug 2018 09:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535041102; cv=none; d=google.com; s=arc-20160816; b=NILVDGP6lMCRBdgHB5z89LFypngPyBGwhb09Al94Kzyt0i7ugqpWcEdtk6q8wyFGnO F+Vji9SWlD14ymjcFYfaTpA7vwBKskuqmum+/rPm8BeWeYgfMLSMkMWTOCVrdiRvYDtw uMXTHdQWnryVkAfA6u0UwJtaJy2V4iIVjSGqj6FLRJ0Ha0/UAnBDph+MdJ8FLtK4P6ZA d26THxHg1qAKVbWSGxwzKclAuKIxvR5+H7eFMVKG2AWvT63k+Se+L9/tQzSya7tOUWZ9 XZePscOkdNKHVkoz3xbMwidiSdjK0N0yj19H6pE4DWK5R6jYsbOXqwi9qFpCqwbd999t YjCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=x3X8iTmmDVmbZg+GFO8nNpySozOz0j/Bz+kB94r0EDQ=; b=LKVF0Mfq9rgohZAhP6scACo0fIwD9uWILfZDesSpclzl63fgj8z7GsZHrNfceByh5k F7kQo82GI7mpvVGkDC7nOWjxfQM7OQrZaCgFAHO+aKXtSWKwYSd7jUFeQTaj9r6h7YIm 28UrgzD3vOMLLARzzy7n6qH7nhdLG+awthARmJ1wKsOLC2FKh9VxPte2KU6jhJu+E9mz 0ycw6ysMYKTGSNYPwwai2KAwUdi/g3e06l087iA2ND5BNBW9mhFfRWy0VVmkKYATSFYO 7P6CkbUsWPjqwhM5qem906iO0bxmHppRof8FC8c7iHZwNpNbXGI1mKOk37ePgulTVvIV yVOA== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w15-v6si4259071pga.579.2018.08.23.09.18.07; Thu, 23 Aug 2018 09:18:22 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731558AbeHWPhK (ORCPT + 99 others); Thu, 23 Aug 2018 11:37:10 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:38844 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730955AbeHWPhK (ORCPT ); Thu, 23 Aug 2018 11:37:10 -0400 Received: by mail-ed1-f65.google.com with SMTP id h33-v6so861954edb.5 for ; Thu, 23 Aug 2018 05:07:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=x3X8iTmmDVmbZg+GFO8nNpySozOz0j/Bz+kB94r0EDQ=; b=JpbAlr8X81uOpH5LpcG91ntFPdL9LW2yRPLap6h4I4KTHoL4K39KD1EkkJqPvE/ltB 6PI4/ypXdnii4heuB4Xp6UANzYSRNZY3EaqHe+FyqyZKMjMbPya0mAury258aeyu48JV N/xkiuaE4DNlaRELvrs+3KJ45l7YeqT4SEL1EyI5nM5lH47lwQmQOTOZVzgi8d4Br4Eh bGgvuePD3fhQLZSpJHI2vreOJH3B8P3+RyYlz6vozKLif6wbHJ9XpYzZQdP5XNnNA8Fv LwfdQtUkzh/CNiBK8J5i3PJkKKSqLQS+eqkjQEGnk/gHAUAHDejcPHN0Ia9mIQbmo7OH 1XdA== X-Gm-Message-State: APzg51BLHmtDt5rL9IJFYS7BEp7MrhAXuxUGC0RfMRjNcWY79edREwVW 86deh7Fn5wQvEjyb6OK3yrA= X-Received: by 2002:a50:eb96:: with SMTP id y22-v6mr2361818edr.38.1535026062734; Thu, 23 Aug 2018 05:07:42 -0700 (PDT) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id g54-v6sm2575789edb.47.2018.08.23.05.07.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 05:07:41 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: Tetsuo Handa , , xen-devel@lists.xenproject.org, LKML , Michal Hocko , Boris Ostrovsky , Juergen Gross Subject: [PATCH] xen/gntdev: fix up blockable calls to mn_invl_range_start Date: Thu, 23 Aug 2018 14:07:07 +0200 Message-Id: <20180823120707.10998-1-mhocko@kernel.org> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Hocko 93065ac753e4 ("mm, oom: distinguish blockable mode for mmu notifiers") has introduced blockable parameter to all mmu_notifiers and the notifier has to back off when called in !blockable case and it could block down the road. The above commit implemented that for mn_invl_range_start but both in_range checks are done unconditionally regardless of the blockable mode and as such they would fail all the time for regular calls. Fix this by checking blockable parameter as well. Once we are there we can remove the stale TODO. The lock has to be sleepable because we wait for completion down in gnttab_unmap_refs_sync. Fixes: 93065ac753e4 ("mm, oom: distinguish blockable mode for mmu notifiers") Cc: Boris Ostrovsky Cc: Juergen Gross Signed-off-by: Michal Hocko --- drivers/xen/gntdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index 57390c7666e5..e7d8bb1bee2a 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -519,21 +519,20 @@ static int mn_invl_range_start(struct mmu_notifier *mn, struct gntdev_grant_map *map; int ret = 0; - /* TODO do we really need a mutex here? */ if (blockable) mutex_lock(&priv->lock); else if (!mutex_trylock(&priv->lock)) return -EAGAIN; list_for_each_entry(map, &priv->maps, next) { - if (in_range(map, start, end)) { + if (!blockable && in_range(map, start, end)) { ret = -EAGAIN; goto out_unlock; } unmap_if_in_range(map, start, end); } list_for_each_entry(map, &priv->freeable_maps, next) { - if (in_range(map, start, end)) { + if (!blockable && in_range(map, start, end)) { ret = -EAGAIN; goto out_unlock; } -- 2.18.0