Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1237011ybl; Wed, 28 Aug 2019 11:34:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpvAPpjvKkkNSzWtYa6o1Uo73Zc6ch1QHwdHsDpMX4o2fHkT8g9JO94PKKt4Cn64rDBto7 X-Received: by 2002:a17:90a:26ac:: with SMTP id m41mr5683953pje.59.1567017299789; Wed, 28 Aug 2019 11:34:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567017299; cv=none; d=google.com; s=arc-20160816; b=Shvvsf5YelwhjokSvQoUh+SKSxnQmxVGmPAVvopresEyNqcw3SzsOWKMwze0EeqS6L owJ42BO0vJkJXSvwFk7byjpz1s8eWcZTqeg/pVMG/BTMophSSzVY1uWgw1Ub0lvSEB0+ Fv1y4d8sVDrmjFlC43GCVX0A+k7bJ9R3ETq/xhmZXMiJCt0UQLD0UPne5onQlrooO77z UejxIABbhdXN6Od9v0VTKry7vYNDL08VeS7O+XNd/m8PHpYsHR5Z8snEP23BdeCruQeh GI30eBL73cbVQAjbcJu94/031JatAJ4KquncrqEzkYvJG9o+GEgGKHRJ1hmPZM68r3Ai ofYw== 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=MRw4JAwMK/TegnyayQas2h0SadP2fic7Zv1TUKBel5o=; b=RrGJSOV8vrioK/OhKlZ/0mrmG8vEoN5CTh2gKZH3YoRi2FMze21BBM3U4z1mX3dT+J tNP2kN1g5s58MdNlkH09yqmibgIW+C4ilQLDCv+4yAG486ftTN1vqRVUqf0HniOu20dH 8XlDnwvJLewsnpaHpuEAVW7LqD46BBCIxxE3Anrv/E1vPiiMvwzF7Wif6/vUSLOb0G88 vu4bZHRqIDXVYYGI3ZdBeWtb9Ab3YiF7byluXg5FGdd6hqhLSy1SziTlcG4Oegfp/90u RwVQtL2+aHl6UdAf4pIYyuPD9IMVTOG79Zutq/ZhtkILQRPFrTquAornTirR20GBvli6 XFcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=VeBtF93w; 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 o9si3376154pfp.158.2019.08.28.11.34.43; Wed, 28 Aug 2019 11:34:59 -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=VeBtF93w; 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 S1726837AbfH1Sd0 (ORCPT + 99 others); Wed, 28 Aug 2019 14:33:26 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:39583 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726591AbfH1Sd0 (ORCPT ); Wed, 28 Aug 2019 14:33:26 -0400 Received: by mail-oi1-f194.google.com with SMTP id 16so493963oiq.6 for ; Wed, 28 Aug 2019 11:33:25 -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=MRw4JAwMK/TegnyayQas2h0SadP2fic7Zv1TUKBel5o=; b=VeBtF93wmFWp16gPmYOQv/sDqBZbOhNKDsEFS/r+1ujwicLkHIplTAeOkU/YhRf81U iE//NvDEi7pyMMEhylzy9D5t+BM6uaUww6q7vfD2pt45cZ772YL9Q5ChveoiwVauphCz tHCP8nw7jJgZIkjkReMrHLn/1r1pfE6A0fRcQ= 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=MRw4JAwMK/TegnyayQas2h0SadP2fic7Zv1TUKBel5o=; b=sejR5uJ+hcWpchdR2rbLGst8w9YWr3lIL/7gODRu27Nfz3MovnAkNSh71PZgttrucr yjVu4KKfjka4PExMhflB/ckoR7taqFn2t+9BvOpt+tNM4vdqH+6CgGE5pMqEPOtJpOgl usF7NBJ8dgipnirb6TnNZHrcv+BUbsYNqtDNqTVhjVULr4sPS5Pv5Dl/4L9P3YTZbCdv cJxkph/k+ISK2KxHW/kgP26E7tl1o3kB5sK17lG7F7hWhd4rzxvzzfKEWdvxSGNofpqu uFQpDK/of3diGoR5ICvuf1THhDIfevegUc+i1YqMnR451EDnC5Ep2PC3T/cq5vrTlVfP Yh8w== X-Gm-Message-State: APjAAAWE+J8+ctjoolhD9Izi5lcbqXGgv0UwRFpMvXRCxhbQRRpDOv9X WCZ8LWWaYmVcdlUrc7RiBPWL6WNw/0MFfIejMQrnZA== X-Received: by 2002:aca:6742:: with SMTP id b2mr3778581oiy.14.1567017205105; Wed, 28 Aug 2019 11:33:25 -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> In-Reply-To: <20190827225002.GB30700@ziepe.ca> From: Daniel Vetter Date: Wed, 28 Aug 2019 20:33:13 +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 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. Thanks, Daniel > Also, can we get one more ack on this patch? > > Jason -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch