From patchwork Wed Aug 14 20:20:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11094451 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 EDA0C13AC for ; Wed, 14 Aug 2019 20:20:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD29B28834 for ; Wed, 14 Aug 2019 20:20:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D14382883B; Wed, 14 Aug 2019 20:20:39 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 55ECF28834 for ; Wed, 14 Aug 2019 20:20:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B1676B0008; Wed, 14 Aug 2019 16:20:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 962C26B000A; Wed, 14 Aug 2019 16:20:37 -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 84FCE6B000C; Wed, 14 Aug 2019 16:20:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 6202C6B0008 for ; Wed, 14 Aug 2019 16:20:37 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 177868248AA2 for ; Wed, 14 Aug 2019 20:20:37 +0000 (UTC) X-FDA: 75822151314.03.jail72_54dfd65e6a51 X-HE-Tag: jail72_54dfd65e6a51 X-Filterd-Recvd-Size: 5707 Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Wed, 14 Aug 2019 20:20:36 +0000 (UTC) Received: by mail-ed1-f68.google.com with SMTP id w5so348513edl.8 for ; Wed, 14 Aug 2019 13:20:36 -0700 (PDT) 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=NGoYUnhBV7TeB+3l4wceLC9ZPh9ISIJNJOmyRzHIbHM=; b=B5pmU59ycnYBpryQhhG1Z3DbeM8Nqe5M8v1SwTte2yz8M8LB54A/UjWXYoWpYTn2Uv 5wXLGfAUtYZN5x4CsUBfceRVwXq/4IjhgUmLTFyUKguhiSbuw71qyrATlnjMjT5+NMfu Y1nD5IwF07+NuCcwz0U1msvMGB0mJkgxThOFM= 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=NGoYUnhBV7TeB+3l4wceLC9ZPh9ISIJNJOmyRzHIbHM=; b=E+EXNXNackfES+SAnfMDRuOBA2XFFRc/aLranGNQdUPI2k7py4ZqEebF1Z8OgaSRcG jRauxy8o+zP0Q+6O+o9dJnzOIW0OaNB7SaLajpO/q+fJML0F7yX6dEVfCpsm087p8w6L gq6nPQgta/HudU7I8E0X0KCJbt0Rlmth1K51SBkKb0Jk2O8Cx0sF+y3Ib3GnBJVhOry7 dqsoRhjoiS7z0a39Gz1leeuCrDkuzBYQL5bQLNdPbqUIasNBRZpvo1zWQe+QtK2O5BxC q+s6UJOpusQ4XfXA5Pa8iibPpxU9l74320v8iiXBNGaGNn0wF8irRy2Wprbaxts3N+qU dXTA== X-Gm-Message-State: APjAAAVP+XBYLbcjrYJlBeGWolqc9/vzDBAESXr8JE0+VKOzgIt0MgPZ HawN8c2k5ggyEYNK4ZnmftxC8A== X-Google-Smtp-Source: APXvYqwaJ7x0tLnRLHwbItm2wgIoNWmNw2/2hrhii9cO7U6X/gWZx95a1UP7+c/DHPfmXSg1sNEoMQ== X-Received: by 2002:a17:906:1e85:: with SMTP id e5mr1324797ejj.200.1565814035124; Wed, 14 Aug 2019 13:20:35 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id ns22sm84342ejb.9.2019.08.14.13.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2019 13:20:34 -0700 (PDT) From: Daniel Vetter To: LKML Cc: linux-mm@kvack.org, DRI Development , Intel Graphics Development , Daniel Vetter , Andrew Morton , Michal Hocko , =?utf-8?q?Christian_K=C3=B6nig?= , David Rientjes , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Paolo Bonzini , Jason Gunthorpe , Daniel Vetter Subject: [PATCH 1/5] mm: Check if mmu notifier callbacks are allowed to fail Date: Wed, 14 Aug 2019 22:20:23 +0200 Message-Id: <20190814202027.18735-2-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814202027.18735-1-daniel.vetter@ffwll.ch> References: <20190814202027.18735-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. Inspired by some confusion we had discussing i915 mmu notifiers and whether we could use the newly-introduced return value to handle some corner cases. Until we realized that these are only for when a task has been killed by the oom reaper. An alternative approach would be to split the callback into two versions, one with the int return value, and the other with void return value like in older kernels. But that's a lot more churn for fairly little gain I think. Summary from the m-l discussion on why we want something at warning level: This allows automated tooling in CI to catch bugs without humans having to look at everything. If we just upgrade the existing pr_info to a pr_warn, then we'll have false positives. And as-is, no one will ever spot the problem since it's lost in the massive amounts of overall dmesg noise. v2: Drop the full WARN_ON backtrace in favour of just a pr_warn for the problematic case (Michal Hocko). v3: Rebase on top of Glisse's arg rework. v4: More rebase on top of Glisse reworking everything. v5: Fixup rebase damage and also catch failures != EAGAIN for !blockable (Jason). Also go back to WARN_ON as requested by Jason, so automatic checkers can easily catch bugs by setting panic_on_warn. 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 Cc: Jason Gunthorpe Signed-off-by: Daniel Vetter Reviewed-by: Jason Gunthorpe --- mm/mmu_notifier.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index b5670620aea0..16f1cbc775d0 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -179,6 +179,8 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) pr_info("%pS callback failed with %d in %sblockable context.\n", mn->ops->invalidate_range_start, _ret, !mmu_notifier_range_blockable(range) ? "non-" : ""); + WARN_ON(mmu_notifier_range_blockable(range) || + ret != -EAGAIN); ret = _ret; } } From patchwork Wed Aug 14 20:20:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11094457 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 698941399 for ; Wed, 14 Aug 2019 20:20:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 590CF28800 for ; Wed, 14 Aug 2019 20:20:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CE6D28842; Wed, 14 Aug 2019 20:20:45 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 9DF9A28800 for ; Wed, 14 Aug 2019 20:20:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2AD666B000A; Wed, 14 Aug 2019 16:20:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 25C836B000C; Wed, 14 Aug 2019 16:20: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 101DA6B000D; Wed, 14 Aug 2019 16:20:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id DA9006B000A for ; Wed, 14 Aug 2019 16:20:38 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 6BE6C180AD7C1 for ; Wed, 14 Aug 2019 20:20:38 +0000 (UTC) X-FDA: 75822151356.11.end59_57ed92dafb31 X-HE-Tag: end59_57ed92dafb31 X-Filterd-Recvd-Size: 10123 Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Wed, 14 Aug 2019 20:20:37 +0000 (UTC) Received: by mail-ed1-f67.google.com with SMTP id m44so343633edd.9 for ; Wed, 14 Aug 2019 13:20:37 -0700 (PDT) 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=JoaO8Qe6CY1dfta4yCfl+sTgCnZHzLR+xJsBydvmafY=; b=TB/fDwiRpXDbYnbebe5pI330088X9XJlGQF+2IhRTfDYTMEq0INaebPwZsNsT8LD80 +k2xt/FCnylJAZNGoH8zeEPnqj8+2txInoicG9vpjAfteV/ICjiT5gaNMKKQtYsYkrzg KNkRLGmFFbDP5EJsNKo7E/q8ZnanOmEVhmVQY= 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=JoaO8Qe6CY1dfta4yCfl+sTgCnZHzLR+xJsBydvmafY=; b=kSqH+J6zimjm8RxjxHHr6/ae1qexUgo6z9ML8nZhHM8OCZ/jqvnaAY2s4ojQvMh43n oOxx5wk+KFv4v6YsErJTB1LmFZe9pN3T91AGayD4EVlgGkpUyeIPcFw3LsNmfTCWK4cg gfrVAh00bzhWOfNuZ7nDmyM/3D/QFxIoXoj1i1suAD8fNnKhxv/FasIo/KlNiIyFbgzT 8Wo9UZfx+D7Ca95+17vDyQNfWJi2LyrAF9R97Khqafdefyqt/ADRBlrn6CGyYHpOQdXp STiAxZbPQVMoJ1AhndG/KuH/6YTdp45hmd/pZwIWEa2OUyZhOqjzsCltz/Y3PCZPqOHk EZgw== X-Gm-Message-State: APjAAAUVWYHLBpO6CiwDRh9S31GqxLmScZ6f/gUYpsWRKjnHZCV7sggY wtGqZFJwZYMhKh3k1c7eOf3ggA== X-Google-Smtp-Source: APXvYqwfgJdqGV4TaVUUi1ZAyfmEy0estN74mYOzE8kf3NhnJNKCPuqJA+FY/2vvG54TdUF778ZM6A== X-Received: by 2002:a17:906:198e:: with SMTP id g14mr1315533ejd.158.1565814036543; Wed, 14 Aug 2019 13:20:36 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id ns22sm84342ejb.9.2019.08.14.13.20.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2019 13:20:35 -0700 (PDT) From: Daniel Vetter To: LKML Cc: linux-mm@kvack.org, DRI Development , Intel Graphics Development , Daniel Vetter , Jason Gunthorpe , Peter Zijlstra , Ingo Molnar , Andrew Morton , Michal Hocko , David Rientjes , =?utf-8?q?Christian_K=C3=B6nig?= , =?utf-8?b?SsOp?= =?utf-8?b?csO0bWUgR2xpc3Nl?= , Masahiro Yamada , Wei Wang , Andy Shevchenko , Thomas Gleixner , Jann Horn , Feng Tang , Kees Cook , Randy Dunlap , Daniel Vetter Subject: [PATCH 2/5] kernel.h: Add non_block_start/end() Date: Wed, 14 Aug 2019 22:20:24 +0200 Message-Id: <20190814202027.18735-3-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814202027.18735-1-daniel.vetter@ffwll.ch> References: <20190814202027.18735-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 In some special cases we must not block, but there's not a spinlock, preempt-off, irqs-off or similar critical section already that arms the might_sleep() debug checks. Add a non_block_start/end() pair to annotate these. This will be used in the oom paths of mmu-notifiers, where blocking is not allowed to make sure there's forward progress. Quoting Michal: "The notifier is called from quite a restricted context - oom_reaper - which shouldn't depend on any locks or sleepable conditionals. The code should be swift as well but we mostly do care about it to make a forward progress. Checking for sleepable context is the best thing we could come up with that would describe these demands at least partially." Peter also asked whether we want to catch spinlocks on top, but Michal said those are less of a problem because spinlocks can't have an indirect dependency upon the page allocator and hence close the loop with the oom reaper. Suggested by Michal Hocko. v2: - Improve commit message (Michal) - Also check in schedule, not just might_sleep (Peter) v3: It works better when I actually squash in the fixup I had lying around :-/ Cc: Jason Gunthorpe Cc: Peter Zijlstra Cc: Ingo Molnar 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 Cc: Masahiro Yamada Cc: Wei Wang Cc: Andy Shevchenko Cc: Thomas Gleixner Cc: Jann Horn Cc: Feng Tang Cc: Kees Cook Cc: Randy Dunlap Cc: linux-kernel@vger.kernel.org Acked-by: Christian König (v1) Signed-off-by: Daniel Vetter --- include/linux/kernel.h | 10 +++++++++- include/linux/sched.h | 4 ++++ kernel/sched/core.c | 19 ++++++++++++++----- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 4fa360a13c1e..915fd9888afb 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -217,7 +217,9 @@ extern void __cant_sleep(const char *file, int line, int preempt_offset); * might_sleep - annotation for functions that can sleep * * this macro will print a stack trace if it is executed in an atomic - * context (spinlock, irq-handler, ...). + * context (spinlock, irq-handler, ...). Additional sections where blocking is + * not allowed can be annotated with non_block_start() and non_block_end() + * pairs. * * This is a useful debugging help to be able to catch problems early and not * be bitten later when the calling function happens to sleep when it is not @@ -233,6 +235,10 @@ extern void __cant_sleep(const char *file, int line, int preempt_offset); # define cant_sleep() \ do { __cant_sleep(__FILE__, __LINE__, 0); } while (0) # define sched_annotate_sleep() (current->task_state_change = 0) +# define non_block_start() \ + do { current->non_block_count++; } while (0) +# define non_block_end() \ + do { WARN_ON(current->non_block_count-- == 0); } while (0) #else static inline void ___might_sleep(const char *file, int line, int preempt_offset) { } @@ -241,6 +247,8 @@ extern void __cant_sleep(const char *file, int line, int preempt_offset); # define might_sleep() do { might_resched(); } while (0) # define cant_sleep() do { } while (0) # define sched_annotate_sleep() do { } while (0) +# define non_block_start() do { } while (0) +# define non_block_end() do { } while (0) #endif #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) diff --git a/include/linux/sched.h b/include/linux/sched.h index 9f51932bd543..c5630f3dca1f 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -974,6 +974,10 @@ struct task_struct { struct mutex_waiter *blocked_on; #endif +#ifdef CONFIG_DEBUG_ATOMIC_SLEEP + int non_block_count; +#endif + #ifdef CONFIG_TRACE_IRQFLAGS unsigned int irq_events; unsigned long hardirq_enable_ip; diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 2b037f195473..57245770d6cc 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3700,13 +3700,22 @@ static noinline void __schedule_bug(struct task_struct *prev) /* * Various schedule()-time debugging checks and statistics: */ -static inline void schedule_debug(struct task_struct *prev) +static inline void schedule_debug(struct task_struct *prev, bool preempt) { #ifdef CONFIG_SCHED_STACK_END_CHECK if (task_stack_end_corrupted(prev)) panic("corrupted stack end detected inside scheduler\n"); #endif +#ifdef CONFIG_DEBUG_ATOMIC_SLEEP + if (!preempt && prev->state && prev->non_block_count) { + printk(KERN_ERR "BUG: scheduling in a non-blocking section: %s/%d/%i\n", + prev->comm, prev->pid, prev->non_block_count); + dump_stack(); + add_taint(TAINT_WARN, LOCKDEP_STILL_OK); + } +#endif + if (unlikely(in_atomic_preempt_off())) { __schedule_bug(prev); preempt_count_set(PREEMPT_DISABLED); @@ -3813,7 +3822,7 @@ static void __sched notrace __schedule(bool preempt) rq = cpu_rq(cpu); prev = rq->curr; - schedule_debug(prev); + schedule_debug(prev, preempt); if (sched_feat(HRTICK)) hrtick_clear(rq); @@ -6570,7 +6579,7 @@ void ___might_sleep(const char *file, int line, int preempt_offset) rcu_sleep_check(); if ((preempt_count_equals(preempt_offset) && !irqs_disabled() && - !is_idle_task(current)) || + !is_idle_task(current) && !current->non_block_count) || system_state == SYSTEM_BOOTING || system_state > SYSTEM_RUNNING || oops_in_progress) return; @@ -6586,8 +6595,8 @@ void ___might_sleep(const char *file, int line, int preempt_offset) "BUG: sleeping function called from invalid context at %s:%d\n", file, line); printk(KERN_ERR - "in_atomic(): %d, irqs_disabled(): %d, pid: %d, name: %s\n", - in_atomic(), irqs_disabled(), + "in_atomic(): %d, irqs_disabled(): %d, non_block: %d, pid: %d, name: %s\n", + in_atomic(), irqs_disabled(), current->non_block_count, current->pid, current->comm); if (task_stack_end_corrupted(current)) From patchwork Wed Aug 14 20:20:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11094461 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 E0EA41395 for ; Wed, 14 Aug 2019 20:20:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBE2628834 for ; Wed, 14 Aug 2019 20:20:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD4152883B; Wed, 14 Aug 2019 20:20:45 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 CFCA828834 for ; Wed, 14 Aug 2019 20:20:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2F306B000C; Wed, 14 Aug 2019 16:20:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EE3C26B000D; Wed, 14 Aug 2019 16:20: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 D0C3C6B000E; Wed, 14 Aug 2019 16:20:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0123.hostedemail.com [216.40.44.123]) by kanga.kvack.org (Postfix) with ESMTP id ACCA86B000C for ; Wed, 14 Aug 2019 16:20:39 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 4EE108248AA2 for ; Wed, 14 Aug 2019 20:20:39 +0000 (UTC) X-FDA: 75822151398.09.title90_5ab9c4cd444b X-HE-Tag: title90_5ab9c4cd444b X-Filterd-Recvd-Size: 5196 Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Wed, 14 Aug 2019 20:20:38 +0000 (UTC) Received: by mail-ed1-f67.google.com with SMTP id w5so348602edl.8 for ; Wed, 14 Aug 2019 13:20:38 -0700 (PDT) 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=dDjwUmcwSXAq578UY4c9Vj0FS6SCgLfjeiZG1PLwBhc=; b=QQneGltVZyDVKndymgf/V07Lz/mVu4xKZlufq/IsuBlC5+1QN4bp7NWpobW8CC1rIF qIF8ZHgfa3ZzNQCa9U+7EASFdi6fg9QrXsipXLij2jwCn91t6FCHDSnO4dCluu2ktfVm 26tp0nC+Bvb3QHNr2PBbwL8HmhMnTo4N7ChVI= 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=dDjwUmcwSXAq578UY4c9Vj0FS6SCgLfjeiZG1PLwBhc=; b=sJwI9UMgia/djXr29jFZk1hQpBgG0AEqTsm0JkzBBGimTDDK0053h/LxOVr5WT9PFr ILa9zta6MkX/FEb9QOCVb6aF935YScHPqap2VN9G8sG6Sp/cz90syc4pBEoJezG3VeCD s+0TDwULKGbsCHAlngeeGhCfVU14EtQPmXo6vm1oAXV/giX6tnqvnoAf/Cgmf9HGN26z AbnlUsWPMQkR+0yLPJQaJoPna8MbFDw+lRjq2GlZ2oGAqvMcX8B3fMs7GzL4bdsYBw28 QJmYEK7sX8Q0RJpCgeVMxc1nBp1LQcR+NvWlMS60+oLxH/rS8bG4BkXn8BgL99JxrI5g mbyQ== X-Gm-Message-State: APjAAAXk8VCqirl6ZWXTKd5g0rGKT30CHMaxcRS8zk3+/GktwI6QLPmA smyeT6FMp5AZRmno/Q+r56RlrA== X-Google-Smtp-Source: APXvYqzQoXvD/5/BVfPi68WzUkMpSm1CHWB0tkEH2JnEfPgw2NOD1Bv5GUgUamH3qvvNe7OEQP+Ihw== X-Received: by 2002:a17:906:81cb:: with SMTP id e11mr1305807ejx.37.1565814037763; Wed, 14 Aug 2019 13:20:37 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id ns22sm84342ejb.9.2019.08.14.13.20.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2019 13:20:37 -0700 (PDT) From: Daniel Vetter To: LKML Cc: linux-mm@kvack.org, DRI Development , Intel Graphics Development , Daniel Vetter , Jason Gunthorpe , 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 3/5] mm, notifier: Catch sleeping/blocking for !blockable Date: Wed, 14 Aug 2019 22:20:25 +0200 Message-Id: <20190814202027.18735-4-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814202027.18735-1-daniel.vetter@ffwll.ch> References: <20190814202027.18735-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. Inspired by an i915 patch series which did exactly that, because the rules haven't been entirely clear to us. v2: Use the shiny new non_block_start/end annotations instead of abusing preempt_disable/enable. v3: Rebase on top of Glisse's arg rework. v4: Rebase on top of more Glisse rework. Cc: Jason Gunthorpe 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 Reviewed-by: Christian König Reviewed-by: Jérôme Glisse 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 16f1cbc775d0..43a76d030164 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -174,7 +174,13 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) id = srcu_read_lock(&srcu); hlist_for_each_entry_rcu(mn, &range->mm->mmu_notifier_mm->list, hlist) { if (mn->ops->invalidate_range_start) { - int _ret = mn->ops->invalidate_range_start(mn, range); + int _ret; + + if (!mmu_notifier_range_blockable(range)) + non_block_start(); + _ret = mn->ops->invalidate_range_start(mn, range); + if (!mmu_notifier_range_blockable(range)) + non_block_end(); if (_ret) { pr_info("%pS callback failed with %d in %sblockable context.\n", mn->ops->invalidate_range_start, _ret, From patchwork Wed Aug 14 20:20:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11094463 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 B0B6E1399 for ; Wed, 14 Aug 2019 20:20:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F76528800 for ; Wed, 14 Aug 2019 20:20:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93B6428837; Wed, 14 Aug 2019 20:20: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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 EA74F28800 for ; Wed, 14 Aug 2019 20:20:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 790FC6B000D; Wed, 14 Aug 2019 16:20:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6CD946B000E; Wed, 14 Aug 2019 16:20:41 -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 4AAD36B0010; Wed, 14 Aug 2019 16:20:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id 2346F6B000D for ; Wed, 14 Aug 2019 16:20:41 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id C527F442C for ; Wed, 14 Aug 2019 20:20:40 +0000 (UTC) X-FDA: 75822151440.29.cord04_5d962f9c3539 X-HE-Tag: cord04_5d962f9c3539 X-Filterd-Recvd-Size: 6848 Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Wed, 14 Aug 2019 20:20:40 +0000 (UTC) Received: by mail-ed1-f68.google.com with SMTP id f22so369892edt.4 for ; Wed, 14 Aug 2019 13:20:39 -0700 (PDT) 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=U5KwhaOsa05mLs5dKsxyaJ8nPNTkq9L0E7PVwxBUg2k=; b=dtTpZc1TP3phfJWfjZ0TTcGZDEkgZeTx7+tiSVp14czRexPyqDM1gnaVtyCL269PpM uyr+QykzpH67/lUTpJRJ4qgJstssFYUgdSFMP71ckMZGGA6c+b2mIUyn+RNlKV5QMWnf BWavURm9nkk5uzc5rKnkwSgXxYm3JJg1jMKeM= 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=U5KwhaOsa05mLs5dKsxyaJ8nPNTkq9L0E7PVwxBUg2k=; b=Qd+C+YOLYPWF3lflw5XnKGLtyCTnObxqzKyPhYMXY6FIw0GcHMNfQNKFvGfF6wiZWH Kz7JO8udt4Gvpta424ps/0+W2793jsvi1Js6QGfPNPTknYXyOOzxIUK/yxT0/CBBTe5I S4LKfMEXydWV50orO5BYD4aluNCigr76d1qgUYrbvY+wmikAiNqQWQkTviojTGo5nD3G TR3iwZWnTkth/4Ycm0eDcRYSGJW4tgxImg4MYyUaLyYy0IUHeizWIr0Vft3jYDwyiKve wvMteLiaSGeuOpulj5HowyNz06SI/aN0qJo7ww1IHqmW2VQc58DUkWlF2dDY5/2ocd5J E9rw== X-Gm-Message-State: APjAAAXTetN1G2CZRJDdHagCioiPLupREgjLPKSMYDoj+Maas4/PC/8y 7KAt4hG1gAP3+dBqyVGm5U5d1w== X-Google-Smtp-Source: APXvYqwr2QYX0Cwtm9mM9vEmD8lUn0css8IRklo25E0smQh544dGM+PTj5A8hH3aTQAPYL0Qh4N4uw== X-Received: by 2002:a17:907:390:: with SMTP id ss16mr1324369ejb.46.1565814039028; Wed, 14 Aug 2019 13:20:39 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id ns22sm84342ejb.9.2019.08.14.13.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2019 13:20:38 -0700 (PDT) From: Daniel Vetter To: LKML Cc: linux-mm@kvack.org, DRI Development , Intel Graphics Development , Daniel Vetter , Jason Gunthorpe , Chris Wilson , 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 4/5] mm, notifier: Add a lockdep map for invalidate_range_start Date: Wed, 14 Aug 2019 22:20:26 +0200 Message-Id: <20190814202027.18735-5-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814202027.18735-1-daniel.vetter@ffwll.ch> References: <20190814202027.18735-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. v2: Use lock_map_acquire/release() like fs_reclaim, to avoid confusion with this being a real mutex (Chris Wilson). v3: Rebase on top of Glisse's arg rework. Cc: Jason Gunthorpe Cc: Chris Wilson 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 Reviewed-by: Jérôme Glisse Signed-off-by: Daniel Vetter --- include/linux/mmu_notifier.h | 6 ++++++ mm/mmu_notifier.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index b6c004bd9f6a..9dd38c32fc53 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -42,6 +42,10 @@ enum mmu_notifier_event { #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 @@ -310,10 +314,12 @@ static inline void mmu_notifier_change_pte(struct mm_struct *mm, static inline void mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) { + lock_map_acquire(&__mmu_notifier_invalidate_range_start_map); if (mm_has_notifiers(range->mm)) { range->flags |= MMU_NOTIFIER_RANGE_BLOCKABLE; __mmu_notifier_invalidate_range_start(range); } + lock_map_release(&__mmu_notifier_invalidate_range_start_map); } static inline int diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index 43a76d030164..331e43ce6f3c 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -21,6 +21,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 From patchwork Wed Aug 14 20:20:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11094467 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 BAA2E1395 for ; Wed, 14 Aug 2019 20:20:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA1DB28800 for ; Wed, 14 Aug 2019 20:20:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E07828837; Wed, 14 Aug 2019 20:20:48 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 2A04628800 for ; Wed, 14 Aug 2019 20:20:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D16176B000E; Wed, 14 Aug 2019 16:20:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BD9556B0010; Wed, 14 Aug 2019 16:20:42 -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 A4CF56B0266; Wed, 14 Aug 2019 16:20:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id 81CF76B000E for ; Wed, 14 Aug 2019 16:20:42 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 26D098248AA2 for ; Wed, 14 Aug 2019 20:20:42 +0000 (UTC) X-FDA: 75822151524.06.books64_613a28a9c808 X-HE-Tag: books64_613a28a9c808 X-Filterd-Recvd-Size: 4679 Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Wed, 14 Aug 2019 20:20:41 +0000 (UTC) Received: by mail-ed1-f65.google.com with SMTP id w5so348688edl.8 for ; Wed, 14 Aug 2019 13:20:41 -0700 (PDT) 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=8YdsxBm4SorcCs6LR7QkyWK07j5ac679kdHnkcCO8NA=; b=SElBQSnY/MEpHH8627z9LUJO0AwXfwMVSdTTj8+/meirzqVOVaUQig461Ql4grU9BW AVOrqu2gy8FVObWFxEJFZZI9KGDQ9zAPfmV41ZLckaSp17XA9+mEmzFQIBhzh/7c6swP BOywaRmA/1lgbIGeuvAe+e1TOiq/MWLuxLS1U= 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=8YdsxBm4SorcCs6LR7QkyWK07j5ac679kdHnkcCO8NA=; b=k7Cmj4G7jmjCWzFT69MM8IY6S4AmYEL/UYboR7oiaKIs/3Q3h+O4O58+8cwPWC3G2i sdLh/6FaPQ+CGoNxXgYE7sD+g6Pb+avLrt/jcTKXDzmswwl0tNkLP9kjyaoQaKU825fy TMivey+HUZy2Uyqd/cdGa/yIu7Z9gBXc3wB7pZota5TLmUAFXvwOMo5qXVXZvjHaX79r SuaUJh8dkXH0HcLPBdTqz43dwW+m6E1z2aHAJRQOBwJja1ZwnqeSiXXqAn0vYX9vB8n4 dBdV6ax5aARLBzfujimPmLF+Artk5sUw9Q8f3Mml/LsqPcj9nivWVhZCbg/YnvKSiKs1 jejQ== X-Gm-Message-State: APjAAAVGIdjQFlMPBCM91PeJRymEHU8kgxOFWUASPuIVKWMyUI4hu/b9 nWi1KfoDNeK/qzAYF3sqj1gLfg== X-Google-Smtp-Source: APXvYqyP95CvDgYSo4eGFz7IoA7gCAiTTQNCbZZ85IgUxdxzhynRxhcbBwMwFB/O5KsYTtdIbvM0uQ== X-Received: by 2002:aa7:d285:: with SMTP id w5mr1658562edq.134.1565814040425; Wed, 14 Aug 2019 13:20:40 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id ns22sm84342ejb.9.2019.08.14.13.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2019 13:20:39 -0700 (PDT) From: Daniel Vetter To: LKML Cc: linux-mm@kvack.org, DRI Development , Intel Graphics Development , Daniel Vetter , Jason Gunthorpe , Ralph Campbell , John Hubbard , Dan Williams , Dan Carpenter , Matthew Wilcox , Arnd Bergmann , Balbir Singh , Ira Weiny , Souptick Joarder , Andrew Morton , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Daniel Vetter Subject: [PATCH 5/5] mm/hmm: WARN on illegal ->sync_cpu_device_pagetables errors Date: Wed, 14 Aug 2019 22:20:27 +0200 Message-Id: <20190814202027.18735-6-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814202027.18735-1-daniel.vetter@ffwll.ch> References: <20190814202027.18735-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 Similar to the warning in the mmu notifer, warning if an hmm mirror callback gets it's blocking vs. nonblocking handling wrong, or if it fails with anything else than -EAGAIN. Cc: Jason Gunthorpe Cc: Ralph Campbell Cc: John Hubbard Cc: Dan Williams Cc: Dan Carpenter Cc: Matthew Wilcox Cc: Arnd Bergmann Cc: Balbir Singh Cc: Ira Weiny Cc: Souptick Joarder Cc: Andrew Morton Cc: "Jérôme Glisse" Cc: linux-mm@kvack.org Signed-off-by: Daniel Vetter Reviewed-by: Daniel Vetter --- mm/hmm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/hmm.c b/mm/hmm.c index 16b6731a34db..52ac59384268 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -205,6 +205,9 @@ static int hmm_invalidate_range_start(struct mmu_notifier *mn, ret = -EAGAIN; break; } + WARN(ret, "%pS callback failed with %d in %sblockable context\n", + mirror->ops->sync_cpu_device_pagetables, ret, + update.blockable ? "" : "non-"); } up_read(&hmm->mirrors_sem);