Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3219205imu; Sat, 24 Nov 2018 00:23:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/XWv6prUFKh5QzMK9ndHWSziKcuHIVKPO7w4pPYsMBp0a7/cUqzLlO5pnXKZFk6sky9dsbu X-Received: by 2002:a17:902:8346:: with SMTP id z6mr19036144pln.340.1543047790131; Sat, 24 Nov 2018 00:23:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047790; cv=none; d=google.com; s=arc-20160816; b=DEQFftGP/IcDYd4ddk2km1qivRVcPNyGNF2yKbT1Ohxyrhzb7w7Xf64TJwtXBlnNAG WHgTQCpaRHlY7eE9Li4luH2+T7bSE+Sg7hPVfYhnlEuc1V8zhRzN2VRNwkio7fA7+RIC yzrwf6NhQfOJbfJ23gpjTwQ7NaBoyBG5eunXSgSOJWf09MbTld9nhw4i/U7Yoefs+UKb i3iIil9bhexT4sVkQV5nRpjuLc1SW8CEi42yyBEM5UtV9jTYP10UudOX1R+aUsrtu5j0 QcvD/nP5hJeWfMii6xD3qrPRq8PqTfiTxJgE9DFQvK3IDk0nmTxW6F5Szz1yl+JfGXMZ hJJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:reply-to:dkim-signature; bh=6F/QXxnTlrWUviTltTc05PuMEQQxtuWU3eLn6e3BlNI=; b=UF7LQ8By07E0SHwlvGgJ5V+Ht4PIOzz9JHeBdvNi0bU56+Dr96Kr2/ExOxrwdpXCc8 z9gkv967DcYOfby86nPXoUSCVPMGQZmOCaopj8zxp2YDf5YeAkpqJbfG57Db2lR8TcpE 9MrvbNUJWqKx3TZ/U/dizKCH+3BeJGiudmFSk6ueaGlFSknoPHzqKsdGTYy1XfdPy6Jq 7UBcbhh8MphiF08esfrxS23zXNap5zHbd44cNtInqHG5PIjE7tp4M6Jx98R8AfBlEAQI NIkuQBrkxf6ZYN5uJcUjC0wZNj6zXD5jzrh+Z8K3uOncyG8n2MJeROOVySppes7PSbvr /bbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DiDkP7X7; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l132-v6si47642589pfc.263.2018.11.24.00.22.55; Sat, 24 Nov 2018 00:23:10 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=DiDkP7X7; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409149AbeKWU60 (ORCPT + 99 others); Fri, 23 Nov 2018 15:58:26 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:37588 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387808AbeKWU6Z (ORCPT ); Fri, 23 Nov 2018 15:58:25 -0500 Received: by mail-wm1-f67.google.com with SMTP id p2-v6so11418479wmc.2 for ; Fri, 23 Nov 2018 02:14:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=6F/QXxnTlrWUviTltTc05PuMEQQxtuWU3eLn6e3BlNI=; b=DiDkP7X7aYPiEt3uZuBjcLdpqqnYj2mSeW2We/m2GazOpJGvJ2ljBk4lnc3Pd4GLF3 p5n9rQMoLI4lcocy5ARh2jsIvorrQWeGeEvcG36HTdTZdwOCO7JUuMlJ/tRfZ7nJjTIT r06BKf56zlfrqGRVtgXtwS+iDKkbpDOisXxj1lSuwetJvSoDMJZ3E9Y0MhLCv1Ri+Hw8 mIHQSZfCAxs65MssfKJXVgJhzEObdiheMPHl7AHeDkxYBCghqn2nmNwQgexBvbOL6pcP CjZk/h96crJkOt5QltCVaFkXKS385P07dHLWMF3kvycTZy49GSkM8RAvAeLC2m+G26rD Kd1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=6F/QXxnTlrWUviTltTc05PuMEQQxtuWU3eLn6e3BlNI=; b=r8pGZcabR/q5CPX2KYXjvh8wtlB+/RFiFUG+59za17KmeYc5ShT5GMpDWAAR1Jxtxx DA1re2x0A2VT7+inGp4VDaTQhQCRvxa69NUOdy86IkKAJe2bcvAh6U0GZvgDiq1GFGu3 2Ac7x6/tSdXjU6lA8MpAPsxLGo7IGQZukozcc1YHfhfXq5fcUb53m5WXlYWo3YcGG0RC zVCBdZ0fDzFseHZXy+zMrYOHERNwB30jKUJtFkGUUERwZE9+PMr5gwUhl+1m/X3Ljz2E F+sZ7mzAm7c/gnZeDMScTln+0Qz0/Dd2WlY/xeLnlWYwH4/mV2OHUwgLLX41Tr3ZCcl4 U3vg== X-Gm-Message-State: AGRZ1gKFtih5T80JGYA74FxdvUDj73fNZovRPfl1Ih5s7685EDb1ToUH pWUWzxVXFSAWuQFq7F4S4To= X-Received: by 2002:a7b:c003:: with SMTP id c3-v6mr12075741wmb.133.1542968086013; Fri, 23 Nov 2018 02:14:46 -0800 (PST) Received: from ?IPv6:2a02:908:125b:9a00:a142:2be6:b7be:5a3a? ([2a02:908:125b:9a00:a142:2be6:b7be:5a3a]) by smtp.gmail.com with ESMTPSA id d18-v6sm37528859wre.25.2018.11.23.02.14.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Nov 2018 02:14:45 -0800 (PST) Reply-To: christian.koenig@amd.com Subject: Re: [PATCH 2/3] mm, notifier: Catch sleeping/blocking for !blockable To: "Koenig, Christian" , LKML , Linux MM , Intel Graphics Development , DRI Development , Andrew Morton , Michal Hocko , David Rientjes , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Daniel Vetter References: <20181122165106.18238-1-daniel.vetter@ffwll.ch> <20181122165106.18238-3-daniel.vetter@ffwll.ch> <20181123084609.GH4266@phenom.ffwll.local> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <59f25d62-904a-86cf-3daf-88e38d526dcf@gmail.com> Date: Fri, 23 Nov 2018 11:14:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181123084609.GH4266@phenom.ffwll.local> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 23.11.18 um 09:46 schrieb Daniel Vetter: > On Thu, Nov 22, 2018 at 06:55:17PM +0000, Koenig, Christian wrote: >> Am 22.11.18 um 17:51 schrieb Daniel Vetter: >>> 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. >>> >>> 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 >>> --- >>> 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 59e102589a25..4d282cfb296e 100644 >>> --- a/mm/mmu_notifier.c >>> +++ b/mm/mmu_notifier.c >>> @@ -185,7 +185,13 @@ int __mmu_notifier_invalidate_range_start(struct mm_struct *mm, >>> id = srcu_read_lock(&srcu); >>> hlist_for_each_entry_rcu(mn, &mm->mmu_notifier_mm->list, hlist) { >>> if (mn->ops->invalidate_range_start) { >>> - int _ret = mn->ops->invalidate_range_start(mn, mm, start, end, blockable); >>> + int _ret; >>> + >>> + if (IS_ENABLED(CONFIG_DEBUG_ATOMIC_SLEEP) && !blockable) >>> + preempt_disable(); >>> + _ret = mn->ops->invalidate_range_start(mn, mm, start, end, blockable); >>> + if (IS_ENABLED(CONFIG_DEBUG_ATOMIC_SLEEP) && !blockable) >>> + preempt_enable(); >> Just for the sake of better documenting this how about adding this to >> include/linux/kernel.h right next to might_sleep(): >> >> #define disallow_sleeping_if(cond)    for((cond) ? preempt_disable() : >> (void)0; (cond); preempt_disable()) >> >> (Just from the back of my head, might contain peanuts and/or hints of >> errors). > I think these magic for blocks aren't used in the kernel. goto breaks > them, and we use goto a lot. Yeah, good argument. > I think a disallow/allow_sleep() pair with > the conditional preept_disable/enable() calls would be nice though. I can > do that if the overall idea sticks. Sounds like a good idea to me as well. Christian. > -Daniel > >> Christian. >> >>> if (_ret) { >>> pr_info("%pS callback failed with %d in %sblockable context.\n", >>> mn->ops->invalidate_range_start, _ret,