From: Vlastimil Babka Date: Mon, 09 Nov 2020 11:33:46 +0000 Subject: Re: [PATCH v5 1/5] mm: introduce debug_pagealloc_{map,unmap}_pages() helpers Message-Id: <4bd5ae2b-4fc6-73dc-b83b-e71826990946@suse.cz> List-Id: References: <20201108065758.1815-1-rppt@kernel.org> <20201108065758.1815-2-rppt@kernel.org> In-Reply-To: <20201108065758.1815-2-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Mike Rapoport , Andrew Morton Cc: David Hildenbrand , Peter Zijlstra , Benjamin Herrenschmidt , Dave Hansen , linux-mm@kvack.org, Paul Mackerras , Pavel Machek , "H. Peter Anvin" , sparclinux@vger.kernel.org, Christoph Lameter , Will Deacon , linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, Michael Ellerman , x86@kernel.org, Mike Rapoport , Christian Borntraeger , Ingo Molnar , Catalin Marinas , Len Brown , Albert Ou , Vasily Gorbik , linux-pm@vger.kernel.org, Heiko Carstens , David Rientjes , Borislav Petkov , Andy Lutomirski , Paul Walmsley , "Kirill A. Shutemov" , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Pekka Enberg , Palmer Dabbelt , Joonsoo Kim , "Edgecombe, Rick P" , linuxppc-dev@lists.ozlabs.org, "David S. Miller" , "Kirill A . Shutemov" On 11/8/20 7:57 AM, Mike Rapoport wrote: > --- a/mm/slab.c > +++ b/mm/slab.c > @@ -1428,21 +1428,19 @@ static bool is_debug_pagealloc_cache(struct kmem_cache *cachep) > return false; > } > > -#ifdef CONFIG_DEBUG_PAGEALLOC > static void slab_kernel_map(struct kmem_cache *cachep, void *objp, int map) > { > if (!is_debug_pagealloc_cache(cachep)) > return; Hmm, I didn't notice earlier, sorry. The is_debug_pagealloc_cache() above includes a debug_pagealloc_enabled_static() check, so it should be fine to use __kernel_map_pages() directly below. Otherwise we generate two static key checks for the same key needlessly. > > - kernel_map_pages(virt_to_page(objp), cachep->size / PAGE_SIZE, map); > + if (map) > + debug_pagealloc_map_pages(virt_to_page(objp), > + cachep->size / PAGE_SIZE); > + else > + debug_pagealloc_unmap_pages(virt_to_page(objp), > + cachep->size / PAGE_SIZE); > } > > -#else > -static inline void slab_kernel_map(struct kmem_cache *cachep, void *objp, > - int map) {} > - > -#endif > - > static void poison_obj(struct kmem_cache *cachep, void *addr, unsigned char val) > { > int size = cachep->object_size; > @@ -2062,7 +2060,7 @@ int __kmem_cache_create(struct kmem_cache *cachep, slab_flags_t flags) > > #if DEBUG > /* > - * If we're going to use the generic kernel_map_pages() > + * If we're going to use the generic debug_pagealloc_map_pages() > * poisoning, then it's going to smash the contents of > * the redzone and userword anyhow, so switch them off. > */ >