From patchwork Mon Aug 26 20:14: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: 11115505 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A44B16B1 for ; Mon, 26 Aug 2019 20:14:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 41D6221872 for ; Mon, 26 Aug 2019 20:14:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41D6221872 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 20ADC88F1B; Mon, 26 Aug 2019 20:14:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4339C88EA7 for ; Mon, 26 Aug 2019 20:14:40 +0000 (UTC) Received: by mail-ed1-x541.google.com with SMTP id g8so28158523edm.6 for ; Mon, 26 Aug 2019 13:14:40 -0700 (PDT) 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=bUhdeRpbg8gRloy4w33VnXTSeooO5sqpvDT0wx5DMzY=; b=m/i5r8EvQb1WnP/3pUJ4RMLMMuxHHHYQ36TXmIwX1vyD23NjoOIbQeOr8OYwyG+kBE WLjTj3lEusyCBIsvUP8P/R5H+ljM+/hhdqIg3ucGTgRGCGgG/k82muilNyJ4/+EiIUWL KC7m+PdDwPIstytBvOXrxxnS1vdQh8l3yl8UvG/tQ6gA386VKRGID70yXO0GOMtePBcR ZQ6cSz/5CiPTm4dhrl7H8QqmBDMtXo3XQQlnnMUtpmXgkaDF5rtE6WpWThxDPRVOAm2Q xmlzGT6GOlnTfoNfx3sgsylsMbNJy5TJylRVHTfzXC9/iIGNaBO2MNv3tcUQftDhRc8T 8lXg== X-Gm-Message-State: APjAAAWodRtYcb7wvgc227g8Bnn3rlLrVsi2uVPxvsu2bS2Qg8EnBxdB k/NF0yAjI9/ye8FIf8H6BmATcg== X-Google-Smtp-Source: APXvYqwQX5rJn4xiT0PzmoOjk8RceDZHB/u+ViHnJA99I4EPasO1Ql6cGV43P/XDRPUyqHKPLLvlzQ== X-Received: by 2002:aa7:c552:: with SMTP id s18mr21104247edr.0.1566850478492; Mon, 26 Aug 2019 13:14:38 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-96.fiber7.init7.net. [212.51.149.96]) by smtp.gmail.com with ESMTPSA id j25sm3000780ejb.49.2019.08.26.13.14.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 13:14:37 -0700 (PDT) From: Daniel Vetter To: LKML Subject: [PATCH 5/5] mm, notifier: annotate with might_sleep() Date: Mon, 26 Aug 2019 22:14:25 +0200 Message-Id: <20190826201425.17547-6-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190826201425.17547-1-daniel.vetter@ffwll.ch> References: <20190826201425.17547-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 X-Mailman-Original-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=bUhdeRpbg8gRloy4w33VnXTSeooO5sqpvDT0wx5DMzY=; b=QViZPMOCt4TCBDSlKAVCdrC+U37mohUaGpt7t54fKUAJnII/M30PJe3HVgsMvO32I/ JHmsQisAEo+uwv1GVmUHudMfC1x01ExLcWbO28gdRMZiZ/4jYiOIUrGZ6L9+5vRcVnku F9YxwgBgX7xnEA70Wp+hl/fz9/FJFtPM7Z4dQ= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Hocko , Linux MM , Daniel Vetter , DRI Development , Jason Gunthorpe , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , David Rientjes , Daniel Vetter , Andrew Morton , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Since mmu notifiers don't exist for more processes, but could block in interesting places, add some annotations. This should help make sure core mm keeps up its end of the mmu notifier contract. The checks here are outside of all notifier checks because of that. They compile away without CONFIG_DEBUG_ATOMIC_SLEEP. Suggested by Jason. 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 Signed-off-by: Daniel Vetter --- include/linux/mmu_notifier.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index 3f9829a1f32e..8b71813417e7 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -345,6 +345,8 @@ static inline void mmu_notifier_change_pte(struct mm_struct *mm, static inline void mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) { + might_sleep(); + lock_map_acquire(&__mmu_notifier_invalidate_range_start_map); if (mm_has_notifiers(range->mm)) { range->flags |= MMU_NOTIFIER_RANGE_BLOCKABLE; @@ -368,6 +370,9 @@ mmu_notifier_invalidate_range_start_nonblock(struct mmu_notifier_range *range) static inline void mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range) { + if (mmu_notifier_range_blockable(range)) + might_sleep(); + if (mm_has_notifiers(range->mm)) __mmu_notifier_invalidate_range_end(range, false); }