Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp62633ybl; Tue, 27 Aug 2019 15:52:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKotlec7/Ubq3Sl3X+q9RxyfRzlS+S3IgDkeIOnHPQsnNSoEyRXAZ4Togk3nUch9Odo0nw X-Received: by 2002:a62:f245:: with SMTP id y5mr1056373pfl.156.1566946376445; Tue, 27 Aug 2019 15:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566946376; cv=none; d=google.com; s=arc-20160816; b=kKABa5w2svxPRpmIYqlc+WZK0EZa2OTjnkkAIwcXuLlNIccpvg0C9MsJkFSZjZmrzT A6aIAdF84cvRYAUttoS1Zf0BVvpMhOtgvTh5xLo7uHQdlqdILKqpQ6RTn7M+QTzCeyeB 6z26YWqDR3siYskSEgaH56mHJ3TV20woOrXijlOCFec9yPlajvQ7K/gU9nMHD5C6X45d PreIdrtfzWwBoDXVQuBM2s21E5ZpE1lasKeCtKthqgtthKbO+RDjgecVySGXKpGFusHQ M98YgnaRTC6WA1UDgYyqRHvRfXRKU7B3i6mTcu02c3+JBFgQrJrBFUEhpx2V1Pyy8TWk vYXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wvbxx4ccqSopo6dw1T9H2ot9rAMHA6WLEPDaHjHucJY=; b=KUBpCuHLKX3aGaY2R89lOGQBkeoesN55o13Lx2CjYULieAmBuhdB9gflR/UBBHweJP YBYHxteoWkjGkunoPaRabsmFhpMi+/art2JQvkZoUDp7hM/XYrBKBRjvYWGblf97Je+s jUW15pM4z6x59Z7NO7OtQdf8mb/mceQIYaP7uNp69qfM4iqclIXQ49CxEna3magL1FoM pkTLM9hYnlwar2XNEz53AnFWA8gEu8w53rFh5+CPNJUlZ1SY59qaUC5/3VOb6EdeBzD6 3vKQT9eauf7O5arqg53LlxSzN5ixDYE3kdQxD3E7pvWrhuGjTIzpPki5wg4/9ZgbMWWH NxWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=ZK51FUwv; 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 186si645077pgc.248.2019.08.27.15.52.35; Tue, 27 Aug 2019 15:52:56 -0700 (PDT) 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=@ziepe.ca header.s=google header.b=ZK51FUwv; 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 S1726092AbfH0WuE (ORCPT + 99 others); Tue, 27 Aug 2019 18:50:04 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:45150 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725989AbfH0WuE (ORCPT ); Tue, 27 Aug 2019 18:50:04 -0400 Received: by mail-qk1-f193.google.com with SMTP id m2so678989qki.12 for ; Tue, 27 Aug 2019 15:50:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wvbxx4ccqSopo6dw1T9H2ot9rAMHA6WLEPDaHjHucJY=; b=ZK51FUwvHLccMgAA0yWjpHkLs4LFcK2g5UlZlz76bZcr7FZPe2gjulNbPgD0jnIyar XXNn9AS3YfLa6c8O1XeFpP5YJXbcLHD4VcvJEtpEKVjcit7ToBwdJn7yqNz2POkatc6L ncshO5DzUExnF8JCtaP1I3KWUBarRmFWt9q0XNKiBE49HzCXPI2p1xxXOe04ytzaMFpn dnrKpg6aQBozNfP03E/nvYIxXNjYKB3Qx2GJCg5gytAUq0CSVOryjn/VA6GX4L3+of9e mmre0FUekO9C8vzem6bChjRnbmQziqa31OY44dR7wF2ErUekuM7GwNU3EwayaSQJ/GwU Ungg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wvbxx4ccqSopo6dw1T9H2ot9rAMHA6WLEPDaHjHucJY=; b=Kb1NadhitlUezwBVlpt+lUAoUdTCHFNeJED9yW2Ye6Z1QFl3uIpPNmBTBZoqQYPiab TK9vcDbyHNf4kpBil8GZi/m7Ri3ekcQBa6DqeY5IYhSKF0w9p9xMOAhBMGgGTNTTlFoW 2OSr2JV/LoB2n1T67iE5zetroMso0kYN6LZLvKmxIH370sPx99W/gIYxo8ziD0DxxdQz g5YvGFiQB2LqWKhUQxm9oe8kaVbX2UspPDuHdTdWJMwAZC9tnh0R2GrxcuABxDvhDfP1 f5oI1syZVIMmBt2wJSj3OOJG9dhmWkGJ4cCuBX+lqdED4drazTSS68SdZuSm3QDhQc5+ nDGg== X-Gm-Message-State: APjAAAWJNnNSrKucVeTeNVetY4qxbj35Dhg/oBOTG2XeMproHwmBvlZR 38C8j0spkG34XUdZmypCUwownA== X-Received: by 2002:a05:620a:1181:: with SMTP id b1mr1065290qkk.390.1566946203681; Tue, 27 Aug 2019 15:50:03 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-167-216-168.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.167.216.168]) by smtp.gmail.com with ESMTPSA id n21sm267524qtc.70.2019.08.27.15.50.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Aug 2019 15:50:03 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1i2kHq-0002zw-Kb; Tue, 27 Aug 2019 19:50:02 -0300 Date: Tue, 27 Aug 2019 19:50:02 -0300 From: Jason Gunthorpe To: Daniel Vetter Cc: LKML , Linux MM , DRI Development , Peter Zijlstra , Ingo Molnar , Andrew Morton , Michal Hocko , David Rientjes , Christian =?utf-8?B?S8O2bmln?= , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Masahiro Yamada , Wei Wang , Andy Shevchenko , Thomas Gleixner , Jann Horn , Feng Tang , Kees Cook , Randy Dunlap , Daniel Vetter Subject: Re: [PATCH 3/5] kernel.h: Add non_block_start/end() Message-ID: <20190827225002.GB30700@ziepe.ca> References: <20190826201425.17547-1-daniel.vetter@ffwll.ch> <20190826201425.17547-4-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190826201425.17547-4-daniel.vetter@ffwll.ch> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > diff --git a/include/linux/kernel.h b/include/linux/kernel.h > index 4fa360a13c1e..82f84cfe372f 100644 > +++ 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,25 @@ 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) > +/** > + * non_block_start - annotate the start of section where sleeping is prohibited > + * > + * This is on behalf of the oom reaper, specifically when it is calling the mmu > + * notifiers. The problem is that if the notifier were to block on, for example, > + * mutex_lock() and if the process which holds that mutex were to perform a > + * sleeping memory allocation, the oom reaper is now blocked on completion of > + * that memory allocation. Other blocking calls like wait_event() pose similar > + * issues. > + */ > +# define non_block_start() \ > + do { current->non_block_count++; } while (0) > +/** > + * non_block_end - annotate the end of section where sleeping is prohibited > + * > + * Closes a section opened by non_block_start(). > + */ > +# define non_block_end() \ > + do { WARN_ON(current->non_block_count-- == 0); } while (0) check-patch does not like these, and I agree #101: FILE: include/linux/kernel.h:248: +# define non_block_start() \ + do { current->non_block_count++; } while (0) /tmp/tmp1spfxufy/0006-kernel-h-Add-non_block_start-end-.patch:108: WARNING: Single statement macros should not use a do {} while (0) loop #108: FILE: include/linux/kernel.h:255: +# define non_block_end() \ + do { WARN_ON(current->non_block_count-- == 0); } while (0) Please use a static inline? Also, can we get one more ack on this patch? Jason