From patchwork Sun Jun 5 15:25:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12869777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCDBECCA47B for ; Sun, 5 Jun 2022 15:25:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD19C8D0002; Sun, 5 Jun 2022 11:25:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D56808D0001; Sun, 5 Jun 2022 11:25:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD04C8D0002; Sun, 5 Jun 2022 11:25:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AD8518D0001 for ; Sun, 5 Jun 2022 11:25:47 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 82216803A2 for ; Sun, 5 Jun 2022 15:25:47 +0000 (UTC) X-FDA: 79544557134.14.F9ECC77 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by imf04.hostedemail.com (Postfix) with ESMTP id 073214000B for ; Sun, 5 Jun 2022 15:25:25 +0000 (UTC) Received: by mail-ed1-f51.google.com with SMTP id z7so15763732edm.13 for ; Sun, 05 Jun 2022 08:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oBSo6LhPKNDFYlpKsrymkakMP0nVeotmS2LDUe++2Ag=; b=MI2W98/bl4fvsuc7EA8n3jW7RtyXsolzKl8iYKGjUKHxpV+xI4yWBh9si/SfGcnemX Wp8Z6Ka4sKIw3ARIJrGTE81BjutbjE8F98r+5LHsywIlLVbH8ZT9BpS2oa3MAZ3Rs2gu AdGWx4erG8ZpDjcF3eYxvJR82Nlg41YU9S044= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oBSo6LhPKNDFYlpKsrymkakMP0nVeotmS2LDUe++2Ag=; b=gAfmij0exC/RETuHFKfHZAGQFfzjMvlowCAfjnjCjykTu5NT97etn7osIka44cxyQb DPcUef61ipz72xRHMOTrVKWA89LgaOmlBtrNvscRbe2cePqrK6m0PAp54xFjGKMWp7XT Rq6kiiGpRnaZv1VkOxkpiqSaVLSF8I07NSsoyoWi/QFp51ONTPZkAQvToXGzd8rwnNSj SUbv+m7kbbiXqOkGlaPXFbYv8QKTVzv29qmiPyeUcV1O5VyldNvYF9FBQQqqQ/NS2cie iAG6cDCGOSEIJsf7gvDPLWeEY/GUpxcoC467ItpAwzAPQScYV7O1XU2Wh3Knz9bNrujR lERA== X-Gm-Message-State: AOAM533v6hcCAtIOSeBzUGIgwJmaoxhCoZEeeS218O/GxHfQp8SaSayD b9LZZzPI5Cuh4JPzWyDjfraQxg== X-Google-Smtp-Source: ABdhPJyz+DCsoFSlGZIktlTYtkVTK8pml1UNEzc+5GGMb5RBEfVAt3+lSGDPBsrviNR+kw3jH8t97w== X-Received: by 2002:a05:6402:42d4:b0:412:c26b:789 with SMTP id i20-20020a05640242d400b00412c26b0789mr21414271edc.232.1654442745494; Sun, 05 Jun 2022 08:25:45 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id l21-20020a056402125500b0042dddaa8af3sm7051499edw.37.2022.06.05.08.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 08:25:44 -0700 (PDT) From: Daniel Vetter To: LKML Cc: DRI Development , Daniel Vetter , Daniel Vetter , Andrew Morton , linux-mm@kvack.org Subject: [PATCH 1/3] mm/page_alloc: use might_alloc() Date: Sun, 5 Jun 2022 17:25:37 +0200 Message-Id: <20220605152539.3196045-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.36.0 MIME-Version: 1.0 X-Stat-Signature: hnxhgzyc448ku6en8ksku3mgjgzq4iru Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=ffwll.ch header.s=google header.b="MI2W98/b"; dmarc=none; spf=none (imf04.hostedemail.com: domain of daniel.vetter@ffwll.ch has no SPF policy when checking 209.85.208.51) smtp.mailfrom=daniel.vetter@ffwll.ch X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 073214000B X-HE-Tag: 1654442725-953274 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: ... instead of open codding it. Completely equivalent code, just a notch more meaningful when reading. Signed-off-by: Daniel Vetter Cc: Andrew Morton Cc: linux-mm@kvack.org Reviewed-by: David Hildenbrand Reviewed-by: Vlastimil Babka --- mm/page_alloc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2db95780e003..277774d170cb 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5177,10 +5177,7 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order, *alloc_flags |= ALLOC_CPUSET; } - fs_reclaim_acquire(gfp_mask); - fs_reclaim_release(gfp_mask); - - might_sleep_if(gfp_mask & __GFP_DIRECT_RECLAIM); + might_alloc(gfp_mask); if (should_fail_alloc_page(gfp_mask, order)) return false; From patchwork Sun Jun 5 15:25:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12869778 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 713D0C43334 for ; Sun, 5 Jun 2022 15:25:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 265778D0003; Sun, 5 Jun 2022 11:25:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 213AA8D0001; Sun, 5 Jun 2022 11:25:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B8478D0005; Sun, 5 Jun 2022 11:25:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E6D388D0003 for ; Sun, 5 Jun 2022 11:25:47 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id C28EE803A2 for ; Sun, 5 Jun 2022 15:25:47 +0000 (UTC) X-FDA: 79544557134.16.733195D Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by imf23.hostedemail.com (Postfix) with ESMTP id AB127140006 for ; Sun, 5 Jun 2022 15:25:19 +0000 (UTC) Received: by mail-ed1-f53.google.com with SMTP id z7so15763772edm.13 for ; Sun, 05 Jun 2022 08:25:47 -0700 (PDT) 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=f3oII5rEfZoXf7U4b6hs9rpi5sWM6BBnmpd30r2QEOU=; b=PyvPxjctikeWzSfNKXCBFIPiHQj342ETF+dWPSJtdTYhGlMch8kZDbkzZkAyX1rhHD vZ401ub/slIA5YG7R+7EGL6JtPXUmSKeBnMSlw5PZx16vAcARgASoY3pVP9iaOnNox3G 5K+FGbP7qHXBGFM25b//KOjJyLZEDACKFxUT4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f3oII5rEfZoXf7U4b6hs9rpi5sWM6BBnmpd30r2QEOU=; b=BmpT2K5q/I4gxpZeyHkL4gjiKdaNiODqpEwYV71oKwyL8FNwE3YtbIFQidJfhafn6C MXndIoWeYS8pmeDcVODX7x4BntXW0M4KtDWBdNDEhA9Ka/tDh79Mo154cDd5TotY0ZJ9 QSDjJIJjn9sUCbicWyIAyob4sehZoJagXHIp6acVTNibvUlxD9aWmTcAif0YHJk9tVMP sWwpAkGnBoQmKgBiDbre96FAthh4eSzKa6J9IAadK06w4ZjDDQG9k6TweGAtnCev332i kfzf4YyivC4LHf5p753to2ns+LwEhnAc394C5cN02wgQbGQ7Ydz5dhYui223IHxTUdH9 JbRQ== X-Gm-Message-State: AOAM533WBP/gOzMmsOs+JayGdxqrvdIYbg5xfxa6Ic2B2YFOED5FdHQu R71OVIZW93Nv0BYf8cbubTyJXQ== X-Google-Smtp-Source: ABdhPJzO8PurCrRxgpc214KmxgqXebuHnZN2GlgM5MuV0uMe12+HNCSkaguDfuGB/Kq9xPEFTfDOvw== X-Received: by 2002:a05:6402:42d4:b0:416:5cac:a9a0 with SMTP id i20-20020a05640242d400b004165caca9a0mr21618319edc.86.1654442746342; Sun, 05 Jun 2022 08:25:46 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id l21-20020a056402125500b0042dddaa8af3sm7051499edw.37.2022.06.05.08.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 08:25:45 -0700 (PDT) From: Daniel Vetter To: LKML Cc: DRI Development , Daniel Vetter , Daniel Vetter , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , linux-mm@kvack.org Subject: [PATCH 2/3] mm/slab: delete cache_alloc_debugcheck_before() Date: Sun, 5 Jun 2022 17:25:38 +0200 Message-Id: <20220605152539.3196045-2-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220605152539.3196045-1-daniel.vetter@ffwll.ch> References: <20220605152539.3196045-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 X-Stat-Signature: jcghnpbrnpj9zxi6e8ybsw5ae8eaiuko X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=ffwll.ch header.s=google header.b=PyvPxjct; spf=none (imf23.hostedemail.com: domain of daniel.vetter@ffwll.ch has no SPF policy when checking 209.85.208.53) smtp.mailfrom=daniel.vetter@ffwll.ch; dmarc=none X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: AB127140006 X-HE-Tag: 1654442719-924549 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: It only does a might_sleep_if(GFP_RECLAIM) check, which is already covered by the might_alloc() in slab_pre_alloc_hook(). And all callers of cache_alloc_debugcheck_before() call that beforehand already. Signed-off-by: Daniel Vetter Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc: Vlastimil Babka Cc: Roman Gushchin Cc: linux-mm@kvack.org Reviewed-by: David Hildenbrand Acked-by: David Rientjes Reviewed-by: Muchun Song --- mm/slab.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index b04e40078bdf..75779ac5f5ba 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2973,12 +2973,6 @@ static void *cache_alloc_refill(struct kmem_cache *cachep, gfp_t flags) return ac->entry[--ac->avail]; } -static inline void cache_alloc_debugcheck_before(struct kmem_cache *cachep, - gfp_t flags) -{ - might_sleep_if(gfpflags_allow_blocking(flags)); -} - #if DEBUG static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep, gfp_t flags, void *objp, unsigned long caller) @@ -3219,7 +3213,6 @@ slab_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid, size_t orig_ if (unlikely(ptr)) goto out_hooks; - cache_alloc_debugcheck_before(cachep, flags); local_irq_save(save_flags); if (nodeid == NUMA_NO_NODE) @@ -3304,7 +3297,6 @@ slab_alloc(struct kmem_cache *cachep, struct list_lru *lru, gfp_t flags, if (unlikely(objp)) goto out; - cache_alloc_debugcheck_before(cachep, flags); local_irq_save(save_flags); objp = __do_cache_alloc(cachep, flags); local_irq_restore(save_flags); @@ -3541,8 +3533,6 @@ int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size, if (!s) return 0; - cache_alloc_debugcheck_before(s, flags); - local_irq_disable(); for (i = 0; i < size; i++) { void *objp = kfence_alloc(s, s->object_size, flags) ?: __do_cache_alloc(s, flags); From patchwork Sun Jun 5 15:25:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12869779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEF85C433EF for ; Sun, 5 Jun 2022 15:25:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C3468D0005; Sun, 5 Jun 2022 11:25:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 53FBA8D0001; Sun, 5 Jun 2022 11:25:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 364CF8D0005; Sun, 5 Jun 2022 11:25:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 25D8D8D0001 for ; Sun, 5 Jun 2022 11:25:49 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id EF6F080397 for ; Sun, 5 Jun 2022 15:25:48 +0000 (UTC) X-FDA: 79544557176.30.CD06719 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) by imf25.hostedemail.com (Postfix) with ESMTP id 1F976A006A for ; Sun, 5 Jun 2022 15:25:10 +0000 (UTC) Received: by mail-ed1-f50.google.com with SMTP id 25so15517698edw.8 for ; Sun, 05 Jun 2022 08:25:48 -0700 (PDT) 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=AijNSNENsndq1lruXgHmAupjtkvf2lBpkHUQA6jew9s=; b=H0zgmtQMVi6D7id759wg8VhqByApWuQ2eAmgXrVLdr0Q1LBDhY7Kz4vpBWUEF4NhOf XiNPQ4GjBN04uYIBj9rn/FJOfwHB5hceglNc0WlSZbm1ugfm6i9LqALZfCEzOoYvi6yF 92djWVCArm7K7WenfzY12vjC0Kkr0MxID7g4E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AijNSNENsndq1lruXgHmAupjtkvf2lBpkHUQA6jew9s=; b=1ChIlp7O3V6Nf9tRVZrRrY5ADAHxyVXxE2Bv4HW2mveQRu7c45OUqaq5LOe02Le5NN 4ILkcMH8G925Vhd9jSwQhmFTFJ0aLb8yzCkpc10KGKzouJGQkvHVTeDb0wjxv76o4PHX PbkU8BVRQxGQt/2N2namED2khAFqEFKR5DSEaFuYcu3sJgjKFR/TPqNepPyDOkrRjx3G eJHAmNl8thyi2mQIyLz31+UuixsQizE87Qnlp6ROqc/lqbR+PFDYneqFBmkrKvxJqaPf 8h1/d6BCCDTchXDly7217/iOq8ESwwRuk9y9RPUzYnVMTlVo5I8WjeGoKwEL85tiZU00 LfEw== X-Gm-Message-State: AOAM5318h/FEDTjXu6KvPQTLHhFDeWcLU2T2Yh8XlEzV390ozoRoO1tT Muio2Xx0mxY0KZY9P/7znShljA== X-Google-Smtp-Source: ABdhPJz8dAE/Co15RJ/4mJpqVwCjyClqDvdCuxcacvEE1TV8+moyX503AYyBnHuJfqgA1ohjLbwB0w== X-Received: by 2002:a05:6402:3484:b0:42e:1f3b:4a4c with SMTP id v4-20020a056402348400b0042e1f3b4a4cmr17457804edc.326.1654442747113; Sun, 05 Jun 2022 08:25:47 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id l21-20020a056402125500b0042dddaa8af3sm7051499edw.37.2022.06.05.08.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 08:25:46 -0700 (PDT) From: Daniel Vetter To: LKML Cc: DRI Development , Daniel Vetter , Daniel Vetter , Andrew Morton , linux-mm@kvack.org Subject: [PATCH 3/3] mm/mempool: use might_alloc() Date: Sun, 5 Jun 2022 17:25:39 +0200 Message-Id: <20220605152539.3196045-3-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220605152539.3196045-1-daniel.vetter@ffwll.ch> References: <20220605152539.3196045-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 X-Stat-Signature: 9j1exdrpy38eg5tc3cpmcbz7cft6ziji X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=ffwll.ch header.s=google header.b=H0zgmtQM; spf=none (imf25.hostedemail.com: domain of daniel.vetter@ffwll.ch has no SPF policy when checking 209.85.208.50) smtp.mailfrom=daniel.vetter@ffwll.ch; dmarc=none X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 1F976A006A X-HE-Tag: 1654442710-11420 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: mempool are generally used for GFP_NOIO, so this wont benefit all that much because might_alloc currently only checks GFP_NOFS. But it does validate against mmu notifier pte zapping, some might catch some drivers doing really silly things, plus it's a bit more meaningful in what we're checking for here. Signed-off-by: Daniel Vetter Cc: Andrew Morton Cc: linux-mm@kvack.org Reviewed-by: Vlastimil Babka --- mm/mempool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mempool.c b/mm/mempool.c index b933d0fc21b8..96488b13a1ef 100644 --- a/mm/mempool.c +++ b/mm/mempool.c @@ -379,7 +379,7 @@ void *mempool_alloc(mempool_t *pool, gfp_t gfp_mask) gfp_t gfp_temp; VM_WARN_ON_ONCE(gfp_mask & __GFP_ZERO); - might_sleep_if(gfp_mask & __GFP_DIRECT_RECLAIM); + might_alloc(gfp_mask); gfp_mask |= __GFP_NOMEMALLOC; /* don't allocate emergency reserves */ gfp_mask |= __GFP_NORETRY; /* don't loop in __alloc_pages */