Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1606929ybe; Tue, 3 Sep 2019 00:29:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvTV0YkwoIQwzro3mc7c7HM624ZLRczvQnRvBwrsKL0wX4684dZy1/gcBy4vhZ6X0UZXJ/ X-Received: by 2002:a17:90a:8d0c:: with SMTP id c12mr2464192pjo.119.1567495784799; Tue, 03 Sep 2019 00:29:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567495784; cv=none; d=google.com; s=arc-20160816; b=MizBfnjEtrZnlQbS+V75F6pTwdd0jUuS6vq63+TfWMDgKkB/tndP77sRKHd7yQOZXW hMiElDd6fSMBytqpzco5pZRlt7MQk5rM+CSEoBSm4rb1nE4iF05xY+vFyJOM26YV8Ygc trV07L1FPqsySfskZS2MqgKByo99QK9+LMKfvsEgw9cgGZRY6xBCklsPfpmRobA7SYIU xloNjpNgtjRuCu5W5Zb/ESjhcP1jwrZ4/1yPAAZXLtFr5LTIXW/BbN9uFVuEjHPIdaY8 S64AMBCYkmuN3KI23/ypqOQ5X0XijTGnHnI29gwfqOTPbXcgJcdOXlpQKn1VFy8/nnlI BpQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=UdMoRPg0KlVqze0pTkNC9rfXaDd7uPSTe82szx43jMg=; b=sKymA7+8UsdBCbAKqd7F0211Hj3Iw/1NwfNncZdC5LFjrM3FwBJXdFKS39372wRnlE xGFq+bw3wuCwk6lXfaCwATsXEwwTJ4kvw/NR34uPBBP8ACiDhU7Bpl5x31VxYxpk4XVh Dm20sNti0mk7cwKSy2yt33QgR770emspaJjrvvjzo9A7hzLMtLImhg9PneUPNoXeTJ1r jgrUGd5L4oO4gzbLDxQKabPBMacqnJ977yo23RWYuzqHO5zmTyTTdGxerjhpA/4q12qj NFjq/5FZbNaAnKqEfQjAHfFSWLf/1qf3AUgSmIpm4TXFjqbyCRnHYaZUo3DWky6mvDi8 j6tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=BRXYASXf; 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 f131si13670020pgc.265.2019.09.03.00.29.29; Tue, 03 Sep 2019 00:29:44 -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=@ffwll.ch header.s=google header.b=BRXYASXf; 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 S1727365AbfICH2g (ORCPT + 99 others); Tue, 3 Sep 2019 03:28:36 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:44216 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbfICH2f (ORCPT ); Tue, 3 Sep 2019 03:28:35 -0400 Received: by mail-ot1-f68.google.com with SMTP id 21so8308350otj.11 for ; Tue, 03 Sep 2019 00:28:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UdMoRPg0KlVqze0pTkNC9rfXaDd7uPSTe82szx43jMg=; b=BRXYASXfXrSYdvQ7cHvdL8g1FGYY5yc7fn4k3rf1HqK5cdyf7DVE1ZRs2ggL6FBlZY jhOxSfrYQhY9BD157Pi5jnSxIhZjG9EG4xisQBVknT3mt+l8TxsfMTbDpomdpXG0MF88 /Ul9+UZc5rqz3oUInM3tk4DRzAXTmO9p25Eds= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UdMoRPg0KlVqze0pTkNC9rfXaDd7uPSTe82szx43jMg=; b=BSX1z3wEx9JMsfvTclVE85X+z7AAB3LElhYIqJtiaIgp6lQECeIooWHn1rQFipZ1fM OYc7fS5qZPdLzpqTzuHl2MU9w238c3iAojz2BSj6LAfdfPpjewTNjV0v8qmj+aIc1f4f GnrqNhQoqraNVjgmBHA2Vk+J+2dhSmnvjvx5PmZ0MuM+nysktt/9aUIqBFQiqbbVsDmG 1etAzKV8HVwnDZpNoE1kXyZdqABdF6S0QWSAXCUrlmmVF1f3ABRIhaLeaeYsh4E9rd18 pCbsEEyTXo0ZZ6zT3LeMz3DgKxvT5zDfPE9zy2JXiGv/dRIwYkkY1Lr7DSPS2BhNkpHL 7dNg== X-Gm-Message-State: APjAAAWX2kPC8/WqmNEkKYEnrBAFzpIZaiugx/t7FP1DB9JFQ+Gv0j9H 0sfRowwrJFeyjffpgabbxnVs+Eoy7I1NVqfw8OrhtA== X-Received: by 2002:a05:6830:1594:: with SMTP id i20mr1193992otr.188.1567495714412; Tue, 03 Sep 2019 00:28:34 -0700 (PDT) MIME-Version: 1.0 References: <20190826201425.17547-1-daniel.vetter@ffwll.ch> <20190826201425.17547-4-daniel.vetter@ffwll.ch> <20190827225002.GB30700@ziepe.ca> <20190828184330.GD933@ziepe.ca> In-Reply-To: From: Daniel Vetter Date: Tue, 3 Sep 2019 09:28:23 +0200 Message-ID: Subject: Re: [PATCH 3/5] kernel.h: Add non_block_start/end() To: Jason Gunthorpe Cc: LKML , Linux MM , DRI Development , Peter Zijlstra , Ingo Molnar , Andrew Morton , Michal Hocko , David Rientjes , =?UTF-8?Q?Christian_K=C3=B6nig?= , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Masahiro Yamada , Wei Wang , Andy Shevchenko , Thomas Gleixner , Jann Horn , Feng Tang , Kees Cook , Randy Dunlap , Daniel Vetter Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 28, 2019 at 8:56 PM Daniel Vetter wrote: > On Wed, Aug 28, 2019 at 8:43 PM Jason Gunthorpe wrote: > > On Wed, Aug 28, 2019 at 08:33:13PM +0200, Daniel Vetter wrote: > > > On Wed, Aug 28, 2019 at 12:50 AM Jason Gunthorpe wrote: > > > > > > > > > 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? > > > > > > We need get_current() plus the task_struct, so this gets real messy > > > real fast. Not even sure which header this would fit in, or whether > > > I'd need to create a new one. You're insisting on this or respinning > > > with the do { } while (0) dropped ok. > > > > My prefernce is always a static inline, but if the headers are so > > twisty we need to use #define to solve a missing include, then I > > wouldn't insist on it. > > Cleanest would be a new header I guess, together with might_sleep(). > But moving that is a bit much I think, there's almost 500 callers of > that one from a quick git grep > > > If dropping do while is the only change then I can edit it in.. > > I think we have the acks now > > Yeah sounds simplest, thanks. Hi Jason, Do you expect me to resend now, or do you plan to do the patchwork appeasement when applying? I've seen you merged the other patches (thanks!), but not these two here. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch