Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3012906imu; Fri, 23 Nov 2018 19:20:55 -0800 (PST) X-Google-Smtp-Source: AJdET5e4H1MIBqYijTzvihTd/MXg91XT10ofFXjUGBLLeeFoozG1F5CsZWu2bA2Us5hYT4JfTzbC X-Received: by 2002:a62:fc86:: with SMTP id e128mr19474519pfh.54.1543029655306; Fri, 23 Nov 2018 19:20:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543029655; cv=none; d=google.com; s=arc-20160816; b=d82t4s2bLnE03WQ79Wr99ib23242A6DLImDNUwZ/WVbyPJ7DdnnYnFf2/jFgAsT+7I 4wXrXs2cQd/lOnMNXL1CNhXr8OsWe9N7mKbdXcBU5vCKxELizxvr+gXvnyCtpJyDV2EE j7G6qiXPxEr5dhcS1byjhzhFYzsULgZQXXrA0h7MoSu5zWvbtyqkHJLdvQ3htWftQuxP k25nju0wdroax0+YMDzLpOR+Y0TfyXsC20QEnaNg67dz/7Z8pctKZpwTGBLYDx5jgMj7 c1ualGH88cNtywvUYebrB+yVaScl9vrPtqGguvDA26Ot/3R7srkOtKJJbU08U4bu9ofi s5Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IgwJtKz/bAk5V2diWi6f2OFLQxM1W0dMUc8sKowBqdg=; b=nhq2sj65HGa1XlZyg3izwKQM69QtcGGHJjOfmlmD2sPmfJolP1wn33fKH5XNk3/VOf TiHuGKcGtVckEVoHm5SKmqbTOWKGs9raEJL2KSt0g0dQPL4mKkUwoa/wNr7R7LX9dUnQ Hap1IdwZnyxjEBRnlT0JrUflx8up2V17H+qft0JFEnzOAtdIvRTW33NpnTQt1RFO3Wed pCOO5EOvesY1POMMLJOnPciNd4DAk2mYDhRPAY37aNCY1jR9X0R8/35arM93G49D8BrH 4dxCW1TClqBGxLzZ3Qq3bY4SseZq2dZQT373sSNTmMNF7XhQUdwtzwNs4VtjCvLfcg/B JDqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=Q4vTJ8Gd; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si54772400pgq.535.2018.11.23.19.20.41; Fri, 23 Nov 2018 19:20:55 -0800 (PST) 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; dkim=pass header.i=@ffwll.ch header.s=google header.b=Q4vTJ8Gd; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406058AbeKWDbh (ORCPT + 99 others); Thu, 22 Nov 2018 22:31:37 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:34284 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387717AbeKWDb2 (ORCPT ); Thu, 22 Nov 2018 22:31:28 -0500 Received: by mail-ed1-f65.google.com with SMTP id b3so8246312ede.1 for ; Thu, 22 Nov 2018 08:51:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IgwJtKz/bAk5V2diWi6f2OFLQxM1W0dMUc8sKowBqdg=; b=Q4vTJ8GdD4KzHoedmPOhf6u2vnzIm7VaUt5yUjAKQ6T0soQqIl+0l/0ncEcEtIvjem z05dSmCFY7Hcm/qUPGHlGjuR6FRGsyE5NkQa8lDut75Gqo5six8q3eKJyRc8XKeO13Zx +DMpwbTdLPRC1Fr/h3BezrEU62/W5kyvDGAaI= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=IgwJtKz/bAk5V2diWi6f2OFLQxM1W0dMUc8sKowBqdg=; b=pQ6sPqRC8+jjToSPdX4BYCcVRzlcXg1gt+RlPoN9UK7X3StYxtfXt0ZLLe/SAlTsRq 46Ku8cDo8xy0gYYsP7M+1daYMJLhPN8UHsFItZXVo9hAQM01T3HUzHn7h5x8CJOHfk7s 9fr4qhpSx93jl7nuDKSRiWoaz32X3+8DaEFkHmHotZ8rx4ff0+OO9kqiI52i68pKrXm9 0GE+6aFRalORNjV2fk7C5b+OrYkydEAp8hXYYF9PVsSWNvzdzK7j+LiNyd564mEMt5Fa zoy+awKVX/5y4HCJ951aCW9QtZLrvAjAIH/TnqjgXSwtakIjWUqpd2vagIUFHGxUYAkY ieiA== X-Gm-Message-State: AA+aEWbBPmYrSjaA/ltniBwmInG7s+VrSBP2knb0IDdowpLAD8srLTY0 yDqEDbbYZIEWqM7Ionhb8qz5Np4N6cY= X-Received: by 2002:a17:906:3b11:: with SMTP id g17-v6mr8689028ejf.210.1542905475467; Thu, 22 Nov 2018 08:51:15 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id s12sm12914780edb.43.2018.11.22.08.51.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 08:51:14 -0800 (PST) From: Daniel Vetter To: LKML Cc: Linux MM , Intel Graphics Development , DRI Development , Daniel Vetter , Andrew Morton , Michal Hocko , David Rientjes , =?UTF-8?q?Christian=20K=C3=B6nig?= , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Daniel Vetter Subject: [PATCH 2/3] mm, notifier: Catch sleeping/blocking for !blockable Date: Thu, 22 Nov 2018 17:51:05 +0100 Message-Id: <20181122165106.18238-3-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181122165106.18238-1-daniel.vetter@ffwll.ch> References: <20181122165106.18238-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 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 59e102589a25..4d282cfb296e 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -185,7 +185,13 @@ int __mmu_notifier_invalidate_range_start(struct mm_struct *mm, id = srcu_read_lock(&srcu); hlist_for_each_entry_rcu(mn, &mm->mmu_notifier_mm->list, hlist) { if (mn->ops->invalidate_range_start) { - int _ret = mn->ops->invalidate_range_start(mn, mm, start, end, blockable); + int _ret; + + if (IS_ENABLED(CONFIG_DEBUG_ATOMIC_SLEEP) && !blockable) + preempt_disable(); + _ret = mn->ops->invalidate_range_start(mn, mm, start, end, blockable); + if (IS_ENABLED(CONFIG_DEBUG_ATOMIC_SLEEP) && !blockable) + preempt_enable(); if (_ret) { pr_info("%pS callback failed with %d in %sblockable context.\n", mn->ops->invalidate_range_start, _ret, -- 2.19.1