From patchwork Mon Aug 27 11:26:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10576997 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 CE4E4174C for ; Mon, 27 Aug 2018 11:26:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE6E6298B7 for ; Mon, 27 Aug 2018 11:26:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B114B298D0; Mon, 27 Aug 2018 11:26:41 +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 428CD298B7 for ; Mon, 27 Aug 2018 11:26:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 027036B4038; Mon, 27 Aug 2018 07:26:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EF30C6B4039; Mon, 27 Aug 2018 07:26:38 -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 D915E6B403A; Mon, 27 Aug 2018 07:26:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 751AC6B4038 for ; Mon, 27 Aug 2018 07:26:38 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id g15-v6so6472349edm.11 for ; Mon, 27 Aug 2018 04:26:38 -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:in-reply-to:references; bh=STAowy5i/Ovr7pcwqADRmxoChyUfmhzfp3gxWxxtQrg=; b=ZQxKB8n88ujp2Q237C2kq5j/E0gxvBwJe1gmYksdH34C5KfjyIBdYjh/0M+RqvQRU6 fJFfGkIVI608th/AJ/fKhQWsF7w0CgWeQtT8a1FANaLHkbDP069C3xVQ8BT07y4fru53 SClH0MeQv3iG4frSIdeY1cUgLuu8USHNadYkQFCGwLP6TpD2hLcGkwrXCMnZ7W+ZrxLR WbxpRWQvq8j+ePSRYLEBHy6wXwUANSPCoqHA04OKvuYUOwjWIrpzHh+Ze96bD1Jr0upu u7PeY58+cIDEvebgygK+pBwnhOq29h/zaNtxW6np/MiVlW3jxe68/rbAmAR5setkn5np POYA== 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: APzg51CM7Zx8JhX5iTH8x9PeB9kuYaWp2v8uSc4axlmPSEiqHe79y0Dz y9R3vRvq93aQBl+kNJWdAx+K+z2x70CbJU8IPIO1546xf4HcoMH3BgEWIJAEHXw9xBY+cbMVuVU a35gth1g173T/Y4X8U8Am+Iys5XiFxUpkCf3chUeTTArHG7ejsGzSmp45qSLIo5R3k9liZcXEjF a9sFQiEyJjKEioyev5qoa2cY46ML8Bkmvr/MvQNXfG883K5B9Kj9t1lzvJRSMbb5YWvRmjc6uSS 4IxgniV1+C5dj8RZJDGMLUDkYZScXyMJHevMrLw+KgikvtiNHZK5+MgqLLp1XZyBGJg9DS5AxFh UvhWk4OKVAS4k2JMJdZ6m5lm8Pxp1XjHTXBSdrPR7RIFiC/+ZWt8gNhRXWQBj3hAo4g1yTbYvA= = X-Received: by 2002:a50:86b5:: with SMTP id r50-v6mr16427722eda.201.1535369197954; Mon, 27 Aug 2018 04:26:37 -0700 (PDT) X-Received: by 2002:a50:86b5:: with SMTP id r50-v6mr16427662eda.201.1535369197091; Mon, 27 Aug 2018 04:26:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535369197; cv=none; d=google.com; s=arc-20160816; b=OZ+0rmULNUVaO4vEF1FKCqZun7Y7SbLl4vTJv/0LJ8VCuceSArDs3jr/UWbP54vApd r6MCVnTZO/1to6diaNNUbPOcvWLHX2QX/PPe15VIYBIvMMJYfnwcvIQ0vBFtTm6MjerA HXKNAyvPrQtQwp5Rvbk30mZv6pOSxG58tWNbkg+GBa166n6k13LQTQJAwFdUIWr9LKMk Fw89y0dv1ommlTRlVJ+znW1Gscc3x0Ppz892rofEO04koiwtei/KRCdnrwvzfV8jp50l 20NSdOv9NQBQuqdJ1CMaI0LVP12/tvmE5tlln7uwTUwT2sJLGJr8CtdXCmOdqy6upLBR sUuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=STAowy5i/Ovr7pcwqADRmxoChyUfmhzfp3gxWxxtQrg=; b=uRshvC8VXWCk/yA98EUTolGD6WVlfHwUZxKqam8V/JVGaifCfwlWhKh6Qf04qK+/uN kSWxiP/y+mHycHmtPWEZTg5VvxibKDWdAT8nGJs0S8SJbLDcWHU4Qm4LhQ5PsCaG+05P 4CH6GVkuofh7stEk+8O7zHk+Wr/3FNYSthNwBm2dEbD8CXE1KKk5CmaHATlujM3dmHJQ 8grUAWw7QSHJ2cv0GRXEsI8CS2i/nlXCap/wpZTQbB5a0eeBqxNs4p08m+R66BJ2k9mn jTha43hAXBIK7KgC1oTLKGk3vZM/45+o/83mMMvZtgUj4fHkFZpWi8BigBYmWs63mtKP AwCg== 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 h30-v6sor3528010ede.57.2018.08.27.04.26.36 for (Google Transport Security); Mon, 27 Aug 2018 04:26:37 -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: ANB0VdZZvx39y8SIVRv6LKINEWVt8/gzqt2GkV12tMIsM+z3ubPdS1IMsggZrvMsyFhjO333Ydpw9Q== X-Received: by 2002:aa7:d28c:: with SMTP id w12-v6mr16823901edq.113.1535369196828; Mon, 27 Aug 2018 04:26:36 -0700 (PDT) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id v1-v6sm6454416edf.3.2018.08.27.04.26.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 04:26:36 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: Tetsuo Handa , , LKML , Michal Hocko , Boris Ostrovsky , Juergen Gross Subject: [PATCH 1/3] xen/gntdev: fix up blockable calls to mn_invl_range_start Date: Mon, 27 Aug 2018 13:26:21 +0200 Message-Id: <20180827112623.8992-2-mhocko@kernel.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827112623.8992-1-mhocko@kernel.org> References: <20180827112623.8992-1-mhocko@kernel.org> 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. Changes since v1 - pull in_range check into mn_invl_range_start - Juergen Fixes: 93065ac753e4 ("mm, oom: distinguish blockable mode for mmu notifiers") Cc: Boris Ostrovsky Cc: Juergen Gross Signed-off-by: Michal Hocko Reviewed-by: Juergen Gross --- drivers/xen/gntdev.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index 57390c7666e5..b0b02a501167 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -492,12 +492,19 @@ static bool in_range(struct gntdev_grant_map *map, return true; } -static void unmap_if_in_range(struct gntdev_grant_map *map, - unsigned long start, unsigned long end) +static int unmap_if_in_range(struct gntdev_grant_map *map, + unsigned long start, unsigned long end, + bool blockable) { unsigned long mstart, mend; int err; + if (!in_range(map, start, end)) + return 0; + + if (!blockable) + return -EAGAIN; + mstart = max(start, map->vma->vm_start); mend = min(end, map->vma->vm_end); pr_debug("map %d+%d (%lx %lx), range %lx %lx, mrange %lx %lx\n", @@ -508,6 +515,8 @@ static void unmap_if_in_range(struct gntdev_grant_map *map, (mstart - map->vma->vm_start) >> PAGE_SHIFT, (mend - mstart) >> PAGE_SHIFT); WARN_ON(err); + + return 0; } static int mn_invl_range_start(struct mmu_notifier *mn, @@ -519,25 +528,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)) { - ret = -EAGAIN; + ret = unmap_if_in_range(map, start, end, blockable); + if (ret) 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)) { - ret = -EAGAIN; + ret = unmap_if_in_range(map, start, end, blockable); + if (ret) goto out_unlock; - } - unmap_if_in_range(map, start, end); } out_unlock: From patchwork Mon Aug 27 11:26:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10576999 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 E77B6174A for ; Mon, 27 Aug 2018 11:26:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D558B298B7 for ; Mon, 27 Aug 2018 11:26:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9D1D298D0; Mon, 27 Aug 2018 11:26:43 +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 70792298B7 for ; Mon, 27 Aug 2018 11:26:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0CEA6B4039; Mon, 27 Aug 2018 07:26:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D9DEB6B403B; Mon, 27 Aug 2018 07:26:39 -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 B6DB06B403C; Mon, 27 Aug 2018 07:26:39 -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 58CE16B4039 for ; Mon, 27 Aug 2018 07:26:39 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id b4-v6so2129196ede.4 for ; Mon, 27 Aug 2018 04:26:39 -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:in-reply-to:references; bh=p42iIwbTrGPV1JR8A37slGiCspSWLnuG5EvrzB1+OHU=; b=FtWEhw/7Br/7nIUgOlKOpSv8pgO/H3yKmpL+iuyY/qDgnXlLBiWM08aMNRqCjeembR b6ghNT967uuRHbmXUufoIYMmMwpEKjPFjYNQw/kfq0+ARzgR+5ySpO6ia2ziu4pP/KnX YjFr6vzvOF5iPWY4lPo5wYjDlH4jbFa3PQmNGnrsipKG+mLJvJIMyDhqmwAt1obFBJU4 fZRvFapDHr7wGrnLOLxUzfr6owmAsnMg/3pZiqQXUeAR+8Dqyt4xEdpS3QE3o9Wbdi5l ptaoi3AT4hpnE72AZO2lPObU96ec0QWUSYYSnEU+MG+rFeJTYNl6e84EpjnuzNZsPwjM 2+9g== 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: APzg51Al1Sy9Fb6kNgjr1TxIJnbiemz+KafucLlcaEQ3riUu6pl2jp+H V4JJVWuWmominvICUN5EdtLFPvKEBfPRwpJ9GCxIlCgPjPg8l9D4IsTIoMov+sCtN8E1/hdIyDp f9tvMKiCrZh9BZUS0mQvIjo59GFgw06bS/lqTgcXjufLNs3OwmuhrAN2TCPs7+8TN6p98pkVeF1 JrgYfzOtkgW9NOtDEwI/hSGQIxO/Xv98w1pfDDK4fvLz+x6lPm1yD0kAwLzqVqPl4RVb8Vuaqfh rm05skk5plqMe8Sv9eKwpxCDgrr0liMf5S4U/mSrxQHiuzSbJ5xXME0Tmfw4FfEnvEYkzT+i1sJ B+dpCQ9aXW6Vu7XH3H9hiftA7MMRbznIpYw8SREeGvhPkL2iHmImyBYACKTf0ucd0f5tccvOJg= = X-Received: by 2002:a50:dd88:: with SMTP id w8-v6mr16823495edk.204.1535369198873; Mon, 27 Aug 2018 04:26:38 -0700 (PDT) X-Received: by 2002:a50:dd88:: with SMTP id w8-v6mr16823439edk.204.1535369198103; Mon, 27 Aug 2018 04:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535369198; cv=none; d=google.com; s=arc-20160816; b=dt5nPFc28aBpgGoSWZKBvDGJeBOaScE7UAAEr9k/QXrQWp41X/Fn4ojPd2v14aNMdq xBvKcmkwP/nLQaNDmtt5M54KhZiCT/N51F+gC5dBpnc5USVqZSXzTGfBNnisW5WL4v0M LBrDTHzig7zdtHtWPIfAVa6eR2GcL/Kw336TIgu/ZzGIRxcQo5+4BFyloLWB3QNOUQvl PsjVxL1nmxYwLmkY/Awf04yyx9I/e31Kxf8QJZR64Vxuva0/le9/yZ0ZSTZc53oVt/io z9RBuEeOYeScLi9s2jpAq+jeVioQ2pomYAkvUJE4Go+eH1A/t2yUwxcv/UwjZnfXBP3w keRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=p42iIwbTrGPV1JR8A37slGiCspSWLnuG5EvrzB1+OHU=; b=FLCeJXPsgs09yYMmuhpYKLOVnunM1jQj0m6ne2x7q3wgHq88bNICmBeWSeGhO8WsAu lXz7kRi/6FgoqpMSLUe8rZ5gAWh0Gk/HJM6Cflxh1Hc94XqScQTj5KzHy/x3fR2oVFuk fO1GeEUzgFG45eaznmrhtr486Z6L1VmVTgXIrbuAjWxKtDuY7iPViTusW2W5sddjN4mM QZoWQNPwXjY5DDkX9/Y1TZgzUti9xHfLHC1DApugKfVEz6+PjL0aTTr9QzZRdMcXqWI9 3yIIla5ikHdgh9qXxkotTS+/CXMSJZXoQJnjb/nRqxyhmHfVafFnbfO52ch657u6BIsi jasA== 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 m44-v6sor504036edm.20.2018.08.27.04.26.37 for (Google Transport Security); Mon, 27 Aug 2018 04:26:38 -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: ANB0Vdb+xhM1ZEfgBmnXBkQhjlEm3WnBtjEDd4mK7LV/prYXDFQUQPWSlF4l3/5siWgQYhK3nC8wiw== X-Received: by 2002:a50:f297:: with SMTP id f23-v6mr16804558edm.40.1535369197863; Mon, 27 Aug 2018 04:26:37 -0700 (PDT) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id v1-v6sm6454416edf.3.2018.08.27.04.26.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 04:26:37 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: Tetsuo Handa , , LKML , Michal Hocko , Jerome Glisse Subject: [PATCH 2/3] mm, mmu_notifier: be explicit about range invalition non-blocking mode Date: Mon, 27 Aug 2018 13:26:22 +0200 Message-Id: <20180827112623.8992-3-mhocko@kernel.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827112623.8992-1-mhocko@kernel.org> References: <20180827112623.8992-1-mhocko@kernel.org> 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 If invalidate_range_start is called for !blocking mode then all callbacks have to guarantee they will no block/sleep. The same obviously applies to invalidate_range_end because this operation pairs with the former and they are called from the same context. Make sure this is appropriately documented. Cc: Jerome Glisse Signed-off-by: Michal Hocko Reviewed-by: Jerome Glisse --- include/linux/mmu_notifier.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index 133ba78820ee..698e371aafe3 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -153,7 +153,9 @@ struct mmu_notifier_ops { * * If blockable argument is set to false then the callback cannot * sleep and has to return with -EAGAIN. 0 should be returned - * otherwise. + * otherwise. Please note that if invalidate_range_start approves + * a non-blocking behavior then the same applies to + * invalidate_range_end. * */ int (*invalidate_range_start)(struct mmu_notifier *mn, From patchwork Mon Aug 27 11:26:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10577001 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 CE75D174C for ; Mon, 27 Aug 2018 11:26:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE345298B7 for ; Mon, 27 Aug 2018 11:26:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B26F5298D0; Mon, 27 Aug 2018 11:26: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 10A49298B7 for ; Mon, 27 Aug 2018 11:26:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 050166B403B; Mon, 27 Aug 2018 07:26:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EF6426B403C; Mon, 27 Aug 2018 07:26:40 -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 D6EA26B403D; Mon, 27 Aug 2018 07:26:40 -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 5EEDD6B403B for ; Mon, 27 Aug 2018 07:26:40 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id b4-v6so2129206ede.4 for ; Mon, 27 Aug 2018 04:26:40 -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:in-reply-to:references; bh=w8FkKqoz4arYOPrFAusP9GIOvx2XYTMfGYJsQt6jYP0=; b=izQoDqSWcXojzFotMUwzNoJE6J/8nual1n0KqUwKgbXhMtXaYgiJS3a8MkX4l05s1E ELvJbd1cHdE6ftMQQ/0xcnXKYIcxCJiTbrOLDnzHCGyhYic19S5OBmYtXRq42J9P3k1D 0Pm57Z1JEngUQNWOfJRBA3Aw3O7wiM6UTSFhBl3qSUDw9mSqLQDAj10CU8NlW+++eHWY M2KSGrC2u+7GkEwh89r2YxuKnNW0qbJIL6615H1OxevzFKE5+QUcYqlkr3xbcHEFQ0sA raktX+IjoLms78+Yncj9W0fu8uzZWoxMu8So5Dxib2fgCUZENFDehU2O5OPxdz0jxBvc cSxg== 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: APzg51CNCPZBhiANtJJ8CYfeSV0JyUWqysvbnWX1tH8twduPXSNN39ys Mo6nJpfBBU/K0WhqjD4nOgLytpF9JWBae5MTXb5YyRkwujAIDOPsOry+v04MKmphHvhRN5I96M4 rIwY4zF/VFn1Gw1UR53ZlSwsd55r1M14GjjFvmb78oLM0YQXFj6HJ48Kd19LWKNBr5IZzwkQ7bw oi9NghfWdt2fiV0UY3U12I8DuvNmXS4cvnns0LNtNPCfgIPVBGFKhMk3qGLj8DFObCgCN1NMr25 w7w6UV0SraP1FJtDrV2MAiy4lfVsObqwTr6NnfM8KfTBidFURe5oJCrumKKfIlS9s5a0jr8Za09 /b4I7X+2bF+1xAzDgv+/G2B9ojFdzgS8bosaAoKgDjoW32ahAsDHMZje7j8LvC2GXFW3s3Ws9A= = X-Received: by 2002:a50:aed8:: with SMTP id f24-v6mr16706023edd.271.1535369199862; Mon, 27 Aug 2018 04:26:39 -0700 (PDT) X-Received: by 2002:a50:aed8:: with SMTP id f24-v6mr16705954edd.271.1535369198957; Mon, 27 Aug 2018 04:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535369198; cv=none; d=google.com; s=arc-20160816; b=de4OIjAr5LoOvAB341h3QGh9FdogSTf1bB/wgPdj9ztwfSbpQg8eYx0MNRDdI2qPrv lrwyoGFWdZGANWV6m0kahYP6R7ZQpl5y13jSELUEcB2U/jqymrfKDeiZqkCgFrDvtywH Hv9Uf3IhuWxA46EqrwSNBaP9GkPN8jQhHx41XkP9EEk7hbRdwGfL7KqNchcnWN1kLFTi uyhFej+fENVASaAzJkjvrYoIjgUXLtUqzo+2DaJt7ZCukBa/gBISbCFiEvbtg2yiygsl 6wHi2KSjfGUgbRefdi2FUCto03lIak8lP8zCZmQrevtcZmYrWSYQK1xDmdyy2/oTg/tu dzyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=w8FkKqoz4arYOPrFAusP9GIOvx2XYTMfGYJsQt6jYP0=; b=TSJnCrVNmah8KXPlHeO/1vdOwxOPoGM9kMJ9WxySAPePsSutOHVymZbxBiDcyEArjp H8pWMOM6n2SodBiZBkAJhB9+2aIe/m41X5H7kBy1Bb1IKspcVLtlyMXDtVFXPyJGWtLi ZIC4x1Tq19IEfo2ZvLXinBulxsvqaV916aUQxNUpODY1AXwpOC3szFXUbCxOQtl2y8eH cBnDxv9FC0IwiKgXIdKK8yAyZs+eqQvl6T6Cm2dX/hY66esOaJXrXcmben8Etg/r7v/J lYK18MNGx5PQhOgcMHRBT9n40gUMzTOIFm5VnOc6hZPATFv+E3voxnfSZgBjeC88PYcN I3vA== 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 l17-v6sor6894097edc.29.2018.08.27.04.26.38 for (Google Transport Security); Mon, 27 Aug 2018 04:26:38 -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: ANB0VdYczqC9Yqxtb1VL1/+NUws5G5DlAbCv50qys7oObdORxml7SUdI60ahxhkBpeh0PbLfjKs3FQ== X-Received: by 2002:aa7:c358:: with SMTP id j24-v6mr6856960edr.100.1535369198652; Mon, 27 Aug 2018 04:26:38 -0700 (PDT) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id v1-v6sm6454416edf.3.2018.08.27.04.26.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 04:26:38 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: Tetsuo Handa , , LKML , Michal Hocko , David Rientjes Subject: [PATCH 3/3] Revert "mm, mmu_notifier: annotate mmu notifiers with blockable invalidate callbacks" Date: Mon, 27 Aug 2018 13:26:23 +0200 Message-Id: <20180827112623.8992-4-mhocko@kernel.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827112623.8992-1-mhocko@kernel.org> References: <20180827112623.8992-1-mhocko@kernel.org> 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 This reverts commit 5ff7091f5a2ca1b7b642ca0dbdede8f693a56926. MMU_INVALIDATE_DOES_NOT_BLOCK flags was the only one used and it is no longer needed since 93065ac753e4 ("mm, oom: distinguish blockable mode for mmu notifiers"). We now have a full support for per range !blocking behavior so we can drop the stop gap workaround which the per notifier flag was used for. Cc: David Rientjes Signed-off-by: Michal Hocko --- drivers/infiniband/hw/hfi1/mmu_rb.c | 1 - drivers/iommu/amd_iommu_v2.c | 1 - drivers/iommu/intel-svm.c | 1 - drivers/misc/sgi-gru/grutlbpurge.c | 1 - include/linux/mmu_notifier.h | 23 --------------------- mm/mmu_notifier.c | 31 ----------------------------- virt/kvm/kvm_main.c | 1 - 7 files changed, 59 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/mmu_rb.c b/drivers/infiniband/hw/hfi1/mmu_rb.c index e1c7996c018e..475b769e120c 100644 --- a/drivers/infiniband/hw/hfi1/mmu_rb.c +++ b/drivers/infiniband/hw/hfi1/mmu_rb.c @@ -77,7 +77,6 @@ static void do_remove(struct mmu_rb_handler *handler, static void handle_remove(struct work_struct *work); static const struct mmu_notifier_ops mn_opts = { - .flags = MMU_INVALIDATE_DOES_NOT_BLOCK, .invalidate_range_start = mmu_notifier_range_start, }; diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c index 58da65df03f5..fd552235bd13 100644 --- a/drivers/iommu/amd_iommu_v2.c +++ b/drivers/iommu/amd_iommu_v2.c @@ -427,7 +427,6 @@ static void mn_release(struct mmu_notifier *mn, struct mm_struct *mm) } static const struct mmu_notifier_ops iommu_mn = { - .flags = MMU_INVALIDATE_DOES_NOT_BLOCK, .release = mn_release, .clear_flush_young = mn_clear_flush_young, .invalidate_range = mn_invalidate_range, diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c index 7d65aab36a96..e16ee247add8 100644 --- a/drivers/iommu/intel-svm.c +++ b/drivers/iommu/intel-svm.c @@ -292,7 +292,6 @@ static void intel_mm_release(struct mmu_notifier *mn, struct mm_struct *mm) } static const struct mmu_notifier_ops intel_mmuops = { - .flags = MMU_INVALIDATE_DOES_NOT_BLOCK, .release = intel_mm_release, .change_pte = intel_change_pte, .invalidate_range = intel_invalidate_range, diff --git a/drivers/misc/sgi-gru/grutlbpurge.c b/drivers/misc/sgi-gru/grutlbpurge.c index be28f05bfafa..03b49d52092e 100644 --- a/drivers/misc/sgi-gru/grutlbpurge.c +++ b/drivers/misc/sgi-gru/grutlbpurge.c @@ -261,7 +261,6 @@ static void gru_release(struct mmu_notifier *mn, struct mm_struct *mm) static const struct mmu_notifier_ops gru_mmuops = { - .flags = MMU_INVALIDATE_DOES_NOT_BLOCK, .invalidate_range_start = gru_invalidate_range_start, .invalidate_range_end = gru_invalidate_range_end, .release = gru_release, diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index 698e371aafe3..9893a6432adf 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -2,7 +2,6 @@ #ifndef _LINUX_MMU_NOTIFIER_H #define _LINUX_MMU_NOTIFIER_H -#include #include #include #include @@ -11,9 +10,6 @@ struct mmu_notifier; struct mmu_notifier_ops; -/* mmu_notifier_ops flags */ -#define MMU_INVALIDATE_DOES_NOT_BLOCK (0x01) - #ifdef CONFIG_MMU_NOTIFIER /* @@ -30,15 +26,6 @@ struct mmu_notifier_mm { }; struct mmu_notifier_ops { - /* - * Flags to specify behavior of callbacks for this MMU notifier. - * Used to determine which context an operation may be called. - * - * MMU_INVALIDATE_DOES_NOT_BLOCK: invalidate_range_* callbacks do not - * block - */ - int flags; - /* * Called either by mmu_notifier_unregister or when the mm is * being destroyed by exit_mmap, always before all pages are @@ -183,10 +170,6 @@ struct mmu_notifier_ops { * Note that this function might be called with just a sub-range * of what was passed to invalidate_range_start()/end(), if * called between those functions. - * - * If this callback cannot block, and invalidate_range_{start,end} - * cannot block, mmu_notifier_ops.flags should have - * MMU_INVALIDATE_DOES_NOT_BLOCK set. */ void (*invalidate_range)(struct mmu_notifier *mn, struct mm_struct *mm, unsigned long start, unsigned long end); @@ -241,7 +224,6 @@ extern void __mmu_notifier_invalidate_range_end(struct mm_struct *mm, bool only_end); extern void __mmu_notifier_invalidate_range(struct mm_struct *mm, unsigned long start, unsigned long end); -extern bool mm_has_blockable_invalidate_notifiers(struct mm_struct *mm); static inline void mmu_notifier_release(struct mm_struct *mm) { @@ -495,11 +477,6 @@ static inline void mmu_notifier_invalidate_range(struct mm_struct *mm, { } -static inline bool mm_has_blockable_invalidate_notifiers(struct mm_struct *mm) -{ - return false; -} - static inline void mmu_notifier_mm_init(struct mm_struct *mm) { } diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index 82bb1a939c0e..5119ff846769 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -247,37 +247,6 @@ void __mmu_notifier_invalidate_range(struct mm_struct *mm, } EXPORT_SYMBOL_GPL(__mmu_notifier_invalidate_range); -/* - * Must be called while holding mm->mmap_sem for either read or write. - * The result is guaranteed to be valid until mm->mmap_sem is dropped. - */ -bool mm_has_blockable_invalidate_notifiers(struct mm_struct *mm) -{ - struct mmu_notifier *mn; - int id; - bool ret = false; - - WARN_ON_ONCE(!rwsem_is_locked(&mm->mmap_sem)); - - if (!mm_has_notifiers(mm)) - return ret; - - id = srcu_read_lock(&srcu); - hlist_for_each_entry_rcu(mn, &mm->mmu_notifier_mm->list, hlist) { - if (!mn->ops->invalidate_range && - !mn->ops->invalidate_range_start && - !mn->ops->invalidate_range_end) - continue; - - if (!(mn->ops->flags & MMU_INVALIDATE_DOES_NOT_BLOCK)) { - ret = true; - break; - } - } - srcu_read_unlock(&srcu, id); - return ret; -} - static int do_mmu_notifier_register(struct mmu_notifier *mn, struct mm_struct *mm, int take_mmap_sem) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index f986e31fa68c..636462edc7ca 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -499,7 +499,6 @@ static void kvm_mmu_notifier_release(struct mmu_notifier *mn, } static const struct mmu_notifier_ops kvm_mmu_notifier_ops = { - .flags = MMU_INVALIDATE_DOES_NOT_BLOCK, .invalidate_range_start = kvm_mmu_notifier_invalidate_range_start, .invalidate_range_end = kvm_mmu_notifier_invalidate_range_end, .clear_flush_young = kvm_mmu_notifier_clear_flush_young,