From patchwork Thu Aug 23 12:07:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10573777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82ED913B6 for ; Thu, 23 Aug 2018 12:07:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71D692B81B for ; Thu, 23 Aug 2018 12:07:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65E462BB56; Thu, 23 Aug 2018 12:07:46 +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 F41042B881 for ; Thu, 23 Aug 2018 12:07:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E75CF6B29F2; Thu, 23 Aug 2018 08:07:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DFD836B29F3; Thu, 23 Aug 2018 08:07:44 -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 C9EFE6B29F4; Thu, 23 Aug 2018 08:07:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 662D86B29F2 for ; Thu, 23 Aug 2018 08:07:44 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id s54-v6so2218986eda.20 for ; Thu, 23 Aug 2018 05:07:44 -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:from:to:cc :subject:date:message-id; bh=x3X8iTmmDVmbZg+GFO8nNpySozOz0j/Bz+kB94r0EDQ=; b=aAPR+EE5eZdvf0YuKQldWr9tAvzHIokzIKbZ2ZcVrbESIVMOedAHFA3E5yCM8XC1Pk 4h1eJJHMuyzm+PXCOG9gC0nlmckac/ivR0AQfb3Lv8ALqIX+SZprm0fzpq/Q0P+GWf90 JTbdXHVMqvFqOEWjMPlp3JBXNWa4bnHid3hVFud9mN4nhivMWKMjKAhU4TIg+72BkbAY 6s17Rt7LB7HJeoxYWlZuGRkqdgXrsCOgdedt0maZEE3K1OkiREj4rhuGoppUfWxTBqVw dOoWxPY9q+8f78N9MLkzLs24io7GUEJ/PlOzkxf9+Tb2WFcwx1UXlqJygGI65DtMNZgz MVTw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: APzg51CiR8uuAlao5lb420oWyc2LIaIZUxFgpxyrdRKO0s2ti2YqgSmK uAzz4qKHFgug8Nv/N7YXXJiCkASuK2bdxIar8u1GV9JXsuLPPe5wyv1zxfq89RT/ppcONqUCmK0 6hqiC//UJ5yrIwYn1RoUaC22TlMgpqU+TZC65YL2eaIuV4HrdLT+x8bfOfRBK+Z0pvdjD/hGLDo roGXuYOY1njeOUcWkOkjp+Bnh2qdKHD3aEAcs75Vd7/GhEJwR/fzVTt5FDgHRgOvZAhz3i/T4t9 LJyKr/LsCKWUaUJfIOHjfpWTT8ktRXfPe9UQe04brjFZRqJKLWPeAaAuhyRm2T6JLiSw5t1H8sY KDdT1bAL8gqHBFUgxojru6UKgUaobIEfHc41BvIE3Ic+nbJ5PU/f0p1cvyGOg2tFNVcBo+C5ig= = X-Received: by 2002:aa7:c384:: with SMTP id k4-v6mr2434446edq.270.1535026063876; Thu, 23 Aug 2018 05:07:43 -0700 (PDT) X-Received: by 2002:aa7:c384:: with SMTP id k4-v6mr2434381edq.270.1535026063049; Thu, 23 Aug 2018 05:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535026063; cv=none; d=google.com; s=arc-20160816; b=l4k/rZ3kgvHwQHRiG4xkQD5ugfVjx5ii1kpnTA9s2tbZEUH4G3CJU64Az6sH6+HhQE 5VY9Rq3h8VVSffE7jf9oB0Oq1G/KVpl8tmTaQX0QCAXIsHwq3JZhUye1H77MVdoi843j Mp9fnFXcHW3uoCo7FxLCi+C6OWFfHKxfrQy67wWRohFx1T+y5c03JBeGH1RCn0/d9KR/ F6Y6dcfJ5NnQ0ScxXoLkCUJBSAnzM35p+8IHT10CMcb9oYwzsBevPNa9b+2YZFhDyWQ7 KRS/TeyByWZ8cT4mI44GFS3nxikw7bqbSutxLsR9IYRbwhZ5OxOUloeKVX7MLI1URQSy wRxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=x3X8iTmmDVmbZg+GFO8nNpySozOz0j/Bz+kB94r0EDQ=; b=ajhJLq2Y16E7fLrVreiOQSsLXUvUjyaWDDwBWE9sbHnWmyFJP/XCN+B3EG7uRGrS4j 1gr1IQ1XBPK23R/vsENHFMjciez9geh2g2ihjCDRZMwUKgmBRI2figpgXEhTQbsAPauC FKBJu8nFCiZHr4dB8QN/7BPkYTJLVH9CLzWizz21h1n2IuVSjnRAf7cLClNYHlb8i/eq xGMZKh4iBS9LHQAQmwFB0p18xiQXdA2tvPfGoWOkoAX+qhqw8kRffvrlC6zfsYK+9kLd GKnPVDEk5vQm3/wXamURqbZO4vljRpTE8IGaFRAyxjURh9hUK0mXBmYmC+4T9Ro8XzKI xmYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z40-v6sor311198edb.43.2018.08.23.05.07.42 for (Google Transport Security); Thu, 23 Aug 2018 05:07:43 -0700 (PDT) Received-SPF: pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Google-Smtp-Source: ANB0Vda6iF8vEY0DK/LMsyJN93ho1ZQKEJo5UUli/HV0fgEThURrntU34PjM4EmQIQHjUnELdHeR/A== 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 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 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 Reviewed-by: Boris Ostrovsky --- 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; }