From patchwork Thu Nov 22 16:51:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10694501 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 0342615A7 for ; Thu, 22 Nov 2018 16:51:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E60A82CC3A for ; Thu, 22 Nov 2018 16:51:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E441A2CCC3; Thu, 22 Nov 2018 16:51:19 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 7295D2CCEF for ; Thu, 22 Nov 2018 16:51:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 681366B2C38; Thu, 22 Nov 2018 11:51:16 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 634546B2C39; Thu, 22 Nov 2018 11:51:16 -0500 (EST) 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 3EDF76B2C3A; Thu, 22 Nov 2018 11:51:16 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id D77B96B2C38 for ; Thu, 22 Nov 2018 11:51:15 -0500 (EST) Received: by mail-ed1-f69.google.com with SMTP id l45so4780037edb.1 for ; Thu, 22 Nov 2018 08:51:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=35SA+A3zSGOUwg2DuEDiDQyYR9o/qAXgi6nZL2aj8/Q=; b=UwUMkkiMjoiEMQFCjc3zZTumP+oPh34mR9axJtTVnU7GrXAHe63T7GqS3NlVoEf2Q8 LoW89vywgMX8nyOvstBzZ00EtIFnXmt8D6NrMBVOSLJOOknE/6Ze3RWRtWhMRm+xUmB6 wAzJZlDEgmJEFgAjQmYHGGodgyCfmCctUu+qS9FrQPni2erDGuY4D6btJN25gZ0sUMqL KN/8F5lHgwDXCWIFA2L30oLi8J+LD5AW6QuHxM/I85BWpQDgUN6wvWMSguys4nNPKZQg 2wU7FV9cmw6fTUgDvoJFHkdvLcxQR3IMsQDId1tTf0AL6NxLt94vk3tpcjZd2onll4pM nGzA== X-Gm-Message-State: AA+aEWYnGm6OIAlvsYPySEg3UjbXSLmX5j4rwO34lw7grkaqrt2qolOz axIRUd5klJaS2cOccHdDLWHGUS+J+Bndl82gXmBXKZcluNXa2dyjj2ls3kXjzON6/UPIxTWFZ3m TI1VgV9yP16auV9ydG1YDn4q2DvzaLLvEy5EUOd0HuV8NgUfVspmzdJ/6HaJ4uGv1wTdDPJwlvn YrD+mtZ9IM0TnCqYVAxSZcxLNIWJZivIJZ8F2RT7U4DDLDXp8N03wZv2794pHywFng6hKbn1/hr AUdfc+P4cd1pA5LgWkSgtmHyU3BVZGIctQyl0BF0BAABzVloJSOtNj2pJYMMoFT7t1mvgofUACd 6233ltj3WlUhwYbAdpBlMS7kr1RlJtuD4GbXXEU/IWRPImz1amMx3uzMNtdeG9EqBFw5gNLp+eK P X-Received: by 2002:a50:b3b8:: with SMTP id s53mr10215649edd.122.1542905475399; Thu, 22 Nov 2018 08:51:15 -0800 (PST) X-Received: by 2002:a50:b3b8:: with SMTP id s53mr10215612edd.122.1542905474570; Thu, 22 Nov 2018 08:51:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542905474; cv=none; d=google.com; s=arc-20160816; b=iLb/AuuUXALwTFUAXFk9EnCFk4B2l8bj+kDvWV9AY8dpWl073GV74oyEz8bqpE4Zmj Z5sMC9RQgBFOvaYZTsA1l8q+AEfS+ZrVthQd9zBtlI+yYwzMMGurVe7yKTvdDYnt0vh5 TblVMo9MNBWkBBAyj9pAJrGOXG+5ep75wWYImslaUutjqqb9sCv+oU3HgmGAqdqY0GmH 7YbPrTWY77XK71meh+3peAhsAgqv/xHFkbhyVPDIDZE1wZYVWiLlwDBxfPJm6sE445mV mwgnzTK6pc1P5Yo1+ccI4nIl+2Oorw9HRKnZi8kJEXPMpymURg9HuSo4554Hs51eFEwL I7Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=35SA+A3zSGOUwg2DuEDiDQyYR9o/qAXgi6nZL2aj8/Q=; b=Og8s17vELuJvoY5ZQfKNuLA6z2B/Go88wyqVJpTebJkrNvYae1tXtsIQzvzKT+7wcs Ql7HY6XTuLC+CkM66gih+pE9eEM5o/Yjtn5+z03yhRGxKAxAS1DwpIE7dipBXs5pzrfp Wd5PWo3Esn5UstJLcT0rwVQ6ATX6Vjy9bsGAi+X+h1sgNu9bEx4T8ZPLAiptxvOlkL63 uJ2aztqbfsfeUYWcV1XEuNxQTLQ2VdpE+avp0qeQqowFVmnhrPPK3JBhv48lMFsBoufL v+yP6a2RBJTkAS3UpDRU0qUpefeIYOC7Er/2Rnb/nqfhVak3jv7+OMA34kmP8x5IYZWQ Wmrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=T6LI94Z0; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of daniel.vetter@ffwll.ch) smtp.mailfrom=daniel.vetter@ffwll.ch Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p16-v6sor25801703eds.29.2018.11.22.08.51.14 for (Google Transport Security); Thu, 22 Nov 2018 08:51:14 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of daniel.vetter@ffwll.ch) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=T6LI94Z0; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of daniel.vetter@ffwll.ch) smtp.mailfrom=daniel.vetter@ffwll.ch 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=35SA+A3zSGOUwg2DuEDiDQyYR9o/qAXgi6nZL2aj8/Q=; b=T6LI94Z0asV3yzmoBf2IesRD6VsGBDpIYF984cFK/5uoflQEU62+7Gv+8nL8dSimEH VVRZdWL4nrC7LT8+R6AClQYQf+KnkfZA92h+SBHYngfeeoFcXGNrLQCHsLR54Vv7Llds ZElU3K4qoo2YLnpkZIDN5WzFwtGdErLMEcxIg= X-Google-Smtp-Source: AFSGD/UaEjvJQp9C/3K0fUJG/8rVELf5/0i7gzNYdUB5+WGaWrnZRqdyJkJ9AKcGEmio8EYKSuwHCg== X-Received: by 2002:a50:bdc8:: with SMTP id z8mr3626337edh.46.1542905474153; Thu, 22 Nov 2018 08:51:14 -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.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 08:51:13 -0800 (PST) From: Daniel Vetter To: LKML Cc: Linux MM , Intel Graphics Development , DRI Development , Daniel Vetter , Andrew Morton , Michal Hocko , =?utf-8?q?Christian_K=C3=B6nig?= , David Rientjes , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Paolo Bonzini , Daniel Vetter Subject: [PATCH 1/3] mm: Check if mmu notifier callbacks are allowed to fail Date: Thu, 22 Nov 2018 17:51:04 +0100 Message-Id: <20181122165106.18238-2-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 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 Just a bit of paranoia, since if we start pushing this deep into callchains it's hard to spot all places where an mmu notifier implementation might fail when it's not allowed to. Cc: Andrew Morton Cc: Michal Hocko Cc: "Christian König" Cc: David Rientjes Cc: Daniel Vetter Cc: "Jérôme Glisse" Cc: linux-mm@kvack.org Cc: Paolo Bonzini Signed-off-by: Daniel Vetter Acked-by: Christian König --- mm/mmu_notifier.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index 5119ff846769..59e102589a25 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -190,6 +190,8 @@ int __mmu_notifier_invalidate_range_start(struct mm_struct *mm, pr_info("%pS callback failed with %d in %sblockable context.\n", mn->ops->invalidate_range_start, _ret, !blockable ? "non-" : ""); + WARN(blockable,"%pS callback failure not allowed\n", + mn->ops->invalidate_range_start); ret = _ret; } } From patchwork Thu Nov 22 16:51:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10694503 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 61DCE15A7 for ; Thu, 22 Nov 2018 16:51:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 509032CB8C for ; Thu, 22 Nov 2018 16:51:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E7942CD5D; Thu, 22 Nov 2018 16:51:21 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 C70892CB8C for ; Thu, 22 Nov 2018 16:51:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E51596B2C3A; Thu, 22 Nov 2018 11:51:17 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D85BE6B2C3B; Thu, 22 Nov 2018 11:51:17 -0500 (EST) 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 C7C156B2C3C; Thu, 22 Nov 2018 11:51:17 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 6288F6B2C3A for ; Thu, 22 Nov 2018 11:51:17 -0500 (EST) Received: by mail-ed1-f71.google.com with SMTP id o21so1369328edq.4 for ; Thu, 22 Nov 2018 08:51:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=IgwJtKz/bAk5V2diWi6f2OFLQxM1W0dMUc8sKowBqdg=; b=alEm0j23Q1TYP/WL4bnuC5bu3AoSSesX4P7PdhvFHYCY44R7iBqn+Lxh1vY0oIPshE cDKH5sjlE1hFUk8/LT8xyu091oNeziE2EPqGejDwBIu/Q3o1RIKwntB0zqP8kk9hDSw5 IZF8VeVWAWdQcVfrz1bozYjPa85Z17jtEKB00VWZ1f2x4uS5Y6TSWbS03hW31wxaTpuo yz9dZod2pEMCWujf/DT0PEcyWqnIrXHMTITe1weONjBidXNyLtb9k83KRMnAHqnivV6l Dv3Q9LWjJDcdLH4NEyVLmUKccD8syFRCtKJRtMgnJyvZ4CqcF1EmTGH65a2DaHXIm/ME Qb+w== X-Gm-Message-State: AGRZ1gJSkn9hK9rJqxM3TRZj0l3g9WL3m+PvltuDDF9InXxjkX/RV1GJ 6ELRmhwwDTd94K3KND40FAs+03PDF0EC4GY+goLDaxNWZY2FiPqje3oc/bplTSlLFSgk3Z84UUl KTnRi1IMQFvZQd2d8t0v8jXGPNJIu9oWm0MZ6Nr/7jXbO2MI7/Co7ZD7iB5OOC8H8EocUR+fsVe fJJXqkvNv5zgq+OBtnZbmrDX0lyhczVn3rNNHo7475QqOU65HrwUOg8ysJ737xWUAnDFIk6Jlht ysxZyYpc9L0cWJRznaubtqpig2ECZySsmLBbsc+DKP99f0WVKVA8580Ve2gwt0rXQnMZc5RTWiB f1ymCPScLDNUGpJ9ICNgdwOmX4Q6MQyi7JpPBMY1LJJC82WRxE5eobbefZrDJU6DFGPvexbg80/ P X-Received: by 2002:a17:906:9613:: with SMTP id s19-v6mr8580746ejx.109.1542905476878; Thu, 22 Nov 2018 08:51:16 -0800 (PST) X-Received: by 2002:a17:906:9613:: with SMTP id s19-v6mr8580706ejx.109.1542905475857; Thu, 22 Nov 2018 08:51:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542905475; cv=none; d=google.com; s=arc-20160816; b=Qq0NxLddZ0WYzuu7Eow2Frdg5Qa3DjLyTk/mwtlXRnGXhFQl6FHhlztcXsY1HAo27Q BzqyCW2X/5hw6IxVK3d0z+mcFuDh9wXUYZR6KRzdBPe9QR+BdKfheQjpF20SfwTtGxrF Tg7F0qyybu+vBt7H8s1oZkRa719uDQalOOTpN4qoSkeP7HoG8/1Yhcx/W6XR850212Z3 x3iV8abIr1oaSy1xCv9ABCOFxw8tSMGZd+fA86wH0SbpJ2b35b9GlElvTrHOm0KeotCd FbZxQNuwkuoTPMQxxqKTfOlXHsiMOy2G+I0G6406EIDUoWsXfd/wLUSQR3d1fcZsv7h8 2OQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=IgwJtKz/bAk5V2diWi6f2OFLQxM1W0dMUc8sKowBqdg=; b=dDo3bY/BJMXNM9jKofMph4HPBPUFZyeGxErz6CAYbLu0zPsoahiTxznmf+v6xkqvWw G42kwFwdabShNSJxsGZKC4+4EZLeiCsN8Ihdl6nvdQLkyiqm5s5QerMPnzwckLzp+0ma NbI+Eqp0/QzlBYQGiZp1wRxK1/QbWJ9GEq3frdeCQaI6s1SNnAhPpv5Luwvo7BtGsm48 y0hLdMly9tGvALStHGeR+fb3zfmEvtZzFRFdME45WcnrpVe5XlSS4HTRIQotrhYkEonR cwwydtow2OJdCBIiChpwey676PqtqWLNFS4c5ti73IH5BCHVGJkGFQ5E0ipk3/g0WOWN 8Hcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=Q4vTJ8Gd; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of daniel.vetter@ffwll.ch) smtp.mailfrom=daniel.vetter@ffwll.ch Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z6-v6sor5056633ejq.44.2018.11.22.08.51.15 for (Google Transport Security); Thu, 22 Nov 2018 08:51:15 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of daniel.vetter@ffwll.ch) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=Q4vTJ8Gd; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of daniel.vetter@ffwll.ch) smtp.mailfrom=daniel.vetter@ffwll.ch 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-Smtp-Source: AJdET5f7D95UNLjpN3z6CjQVNTRkjvktjeA+ZinA1S4SxGyQ/8odF3x2QRcRsfY9v4Pi6Pu0SMQitA== 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_K=C3=B6nig?= , =?utf-8?b?SsOp?= =?utf-8?b?csO0bWUgR2xpc3Nl?= , 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 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 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, From patchwork Thu Nov 22 16:51:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10694507 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 186C75A4 for ; Thu, 22 Nov 2018 16:51:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0601D2CD19 for ; Thu, 22 Nov 2018 16:51:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED2902CD5D; Thu, 22 Nov 2018 16:51:23 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 DBE7C2CD19 for ; Thu, 22 Nov 2018 16:51:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 300E76B2C3B; Thu, 22 Nov 2018 11:51:19 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2B36D6B2C3C; Thu, 22 Nov 2018 11:51:19 -0500 (EST) 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 0B8136B2C3D; Thu, 22 Nov 2018 11:51:19 -0500 (EST) 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 A71F96B2C3B for ; Thu, 22 Nov 2018 11:51:18 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id o21so1369344edq.4 for ; Thu, 22 Nov 2018 08:51:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=IqCNVNv0Y8aoRKucGwKEjdCDvF336AuZYaELjzjP6Ls=; b=Jc/JGlh47d9edFyUTOSA5RzIrEEuveh+AmpksEKQYu5MIrLo4qENIDAgkTDaOgpsSY 8FLVgj/fceWnjEkNyJdXCBNcGVQ0ODZjBsUUvOKZgxgq5KFQEhhc4+2Kt3KZGPsvyS08 0EiW6LdhzIGM7rj5Qz83xNT/DpBETRoW3nFliZS9M3yyLRjGATB/luBtJ4E9DkomWhxk +mIEy9RSNDK5r4JHxzlGIMfRgrPFspsRO+8R6imLV3VENRIqGL29G8rCYvh61GxsA0w7 4aMCtaP0mZ+5G81RxrQLP/gCVduGHNP74vg/BXmck/GVD4Nq135D3B4o5iBvnaTPoMIb 1tfg== X-Gm-Message-State: AA+aEWbK7y/EMkmP06WhBnXikiYgJi2abUM++KnvqcOb/SiHwReyZUC/ fXonrxUlSlAgUoXnL/CJn29fZGbWtnPzdIoKRbU65QeX4rTYc8oA+vH6GX0+KlvHUpR6avb94gw saXAmPbouLRXB7KKIoDiR5OL3Yn4SowIaqWHKtjn9l2Qhnug/7uq+PwZhnkObBzYaIJkuf73AIl LmUuSYdXYkB/N8lyzkq1Jj7h0jRfZ5lpnTYuz7eHEH+0NJuPgMg3BVjz8XaLkDV8i2bjyxPPQHG qgfTMyEoKiwJI7jdxA7eABBXp0JZza4pIOwtqI9d42yb+yw3F7btlwDjCiCY1o3aAARalkDW9sm hWMiNwrFt6iYUnnZXsGJm6zpXBvDzf3smRvst5l81Tl75CV4iaZEdTx2L3cNiMm8GxH7ugQP3q5 N X-Received: by 2002:a50:e045:: with SMTP id g5mr10357933edl.152.1542905478160; Thu, 22 Nov 2018 08:51:18 -0800 (PST) X-Received: by 2002:a50:e045:: with SMTP id g5mr10357876edl.152.1542905477206; Thu, 22 Nov 2018 08:51:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542905477; cv=none; d=google.com; s=arc-20160816; b=RtG6vBkiMvoKoIWGD5JBulfs+f75T8ItbRvew0oHN4GBzkGZNelkAhT5Tm1twi4lTV V70tlu2Hy//hPb6+ObIzNuTnIplxRLz745hAzHaDMZjpf8y04TbxW07ppBYE8XilE0Fx 2skKtSfxwfRDdLXW6B5zvaCrJn9UnSo4SipX5de2KLkPtKm6s2LD4N4KkyZsJwgd/pns gk+6wQq9SgOgsNkkQaqAQRRPF2zJwvOhxWtQsxj9qpbToBIUSZjxJvPhFVFs+jgM3K0O O24ccWsbrSHVRY1e2DHfYk37n3PhiHikgbQQRN1S9zSsd1/JT1Hud7NpWVtAzOTdPL3/ RdvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=IqCNVNv0Y8aoRKucGwKEjdCDvF336AuZYaELjzjP6Ls=; b=OQm6E19KNUd0CGVhUE6IcKCpLCKRgSqAYl/0Ln6Ij5latS2hyYIFD3c3CE7HJCnOdF 45fwX6Y0uh6ZCsSe/NXZHHPmznMQ2a5R9awSJjVTm/EgVzOClUcXYRuJAuMw6HObYbp1 vQdZ2Q5Bdes4xHAYNJnrb0LJd0jquyLmFVjMvERkf2qBc3pi6jY4P23/NG0HasAqnwfD IsoJo8Y96lfHUcu4SnesifOrME5xtXxG2YKWmT4k7ErnTFdA5BZYfXGxox9uo9yrwgJZ clwK+ypoelEnWWdtjAtTPDlIXi5CU2w4iQ5d5g99YioFFoLA6MdnthO5Ol2uF+I3PTLt b6jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b="MMzYO6/w"; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of daniel.vetter@ffwll.ch) smtp.mailfrom=daniel.vetter@ffwll.ch Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b51sor8949498edd.5.2018.11.22.08.51.17 for (Google Transport Security); Thu, 22 Nov 2018 08:51:17 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of daniel.vetter@ffwll.ch) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b="MMzYO6/w"; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of daniel.vetter@ffwll.ch) smtp.mailfrom=daniel.vetter@ffwll.ch 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=IqCNVNv0Y8aoRKucGwKEjdCDvF336AuZYaELjzjP6Ls=; b=MMzYO6/waCjCYerQTkvOeF8GBYcFu0U7oI6tc9TyEKstlXpVLz2o7sa6oi3lFZfhPG v38/v1GFssxWyCYmgz0LqI9Sm+APanFajOvvvpBoCT/nfxyAUye3LZpj1po5QpUN12NU adNcLC9JNMKYMy36LmWpSDW8/uY5Z48mR9P1w= X-Google-Smtp-Source: AFSGD/X3yt1n8EIDxKFM/dx7WPreYbLdq5CVYlgu9XO9dTU/ze5Lq/MSqa8fCcbBo2dSkl61aed9Sg== X-Received: by 2002:a50:fd0e:: with SMTP id i14mr9994539eds.98.1542905476815; Thu, 22 Nov 2018 08:51:16 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 08:51:16 -0800 (PST) From: Daniel Vetter To: LKML Cc: Linux MM , Intel Graphics Development , DRI Development , Daniel Vetter , Andrew Morton , David Rientjes , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Michal Hocko , =?utf-8?q?Christian_K=C3=B6nig?= , Greg Kroah-Hartman , Mike Rapoport , Daniel Vetter Subject: [PATCH 3/3] mm, notifier: Add a lockdep map for invalidate_range_start Date: Thu, 22 Nov 2018 17:51:06 +0100 Message-Id: <20181122165106.18238-4-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 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 This is a similar idea to the fs_reclaim fake lockdep lock. It's fairly easy to provoke a specific notifier to be run on a specific range: Just prep it, and then munmap() it. A bit harder, but still doable, is to provoke the mmu notifiers for all the various callchains that might lead to them. But both at the same time is really hard to reliable hit, especially when you want to exercise paths like direct reclaim or compaction, where it's not easy to control what exactly will be unmapped. By introducing a lockdep map to tie them all together we allow lockdep to see a lot more dependencies, without having to actually hit them in a single challchain while testing. Aside: Since I typed this to test i915 mmu notifiers I've only rolled this out for the invaliate_range_start callback. If there's interest, we should probably roll this out to all of them. But my undestanding of core mm is seriously lacking, and I'm not clear on whether we need a lockdep map for each callback, or whether some can be shared. Cc: Andrew Morton Cc: David Rientjes Cc: "Jérôme Glisse" Cc: Michal Hocko Cc: "Christian König" Cc: Greg Kroah-Hartman Cc: Daniel Vetter Cc: Mike Rapoport Cc: linux-mm@kvack.org Signed-off-by: Daniel Vetter --- include/linux/mmu_notifier.h | 7 +++++++ mm/mmu_notifier.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index 9893a6432adf..a39ba218dbbe 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -12,6 +12,10 @@ struct mmu_notifier_ops; #ifdef CONFIG_MMU_NOTIFIER +#ifdef CONFIG_LOCKDEP +extern struct lockdep_map __mmu_notifier_invalidate_range_start_map; +#endif + /* * The mmu notifier_mm structure is allocated and installed in * mm->mmu_notifier_mm inside the mm_take_all_locks() protected @@ -267,8 +271,11 @@ static inline void mmu_notifier_change_pte(struct mm_struct *mm, static inline void mmu_notifier_invalidate_range_start(struct mm_struct *mm, unsigned long start, unsigned long end) { + mutex_acquire(&__mmu_notifier_invalidate_range_start_map, 0, 0, + _RET_IP_); if (mm_has_notifiers(mm)) __mmu_notifier_invalidate_range_start(mm, start, end, true); + mutex_release(&__mmu_notifier_invalidate_range_start_map, 1, _RET_IP_); } static inline int mmu_notifier_invalidate_range_start_nonblock(struct mm_struct *mm, diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index 4d282cfb296e..c6e797927376 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -23,6 +23,13 @@ /* global SRCU for all MMs */ DEFINE_STATIC_SRCU(srcu); +#ifdef CONFIG_LOCKDEP +struct lockdep_map __mmu_notifier_invalidate_range_start_map = { + .name = "mmu_notifier_invalidate_range_start" +}; +EXPORT_SYMBOL_GPL(__mmu_notifier_invalidate_range_start_map); +#endif + /* * This function allows mmu_notifier::release callback to delay a call to * a function that will free appropriate resources. The function must be