From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.kernel.org ([198.145.29.99]:37128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728354AbgKCMOF (ORCPT ); Tue, 3 Nov 2020 07:14:05 -0500 Date: Tue, 3 Nov 2020 14:13:50 +0200 From: Mike Rapoport Subject: Re: [PATCH v3 2/4] PM: hibernate: make direct map manipulations more explicit Message-ID: <20201103121350.GI4879@kernel.org> References: <20201101170815.9795-1-rppt@kernel.org> <20201101170815.9795-3-rppt@kernel.org> <20201103110816.t6a3ebtgcm7mfogy@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201103110816.t6a3ebtgcm7mfogy@box> List-ID: To: "Kirill A. Shutemov" Cc: Andrew Morton , Albert Ou , Andy Lutomirski , Benjamin Herrenschmidt , Borislav Petkov , Catalin Marinas , Christian Borntraeger , Christoph Lameter , "David S. Miller" , Dave Hansen , David Hildenbrand , David Rientjes , "Edgecombe, Rick P" , "H. Peter Anvin" , Heiko Carstens , Ingo Molnar , Joonsoo Kim , Len Brown , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , Paul Mackerras , Paul Walmsley , Pavel Machek , Pekka Enberg , Peter Zijlstra , "Rafael J. Wysocki" , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pm@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, x86@kernel.org, "Rafael J . Wysocki" On Tue, Nov 03, 2020 at 02:08:16PM +0300, Kirill A. Shutemov wrote: > On Sun, Nov 01, 2020 at 07:08:13PM +0200, Mike Rapoport wrote: > > diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c > > index 46b1804c1ddf..054c8cce4236 100644 > > --- a/kernel/power/snapshot.c > > +++ b/kernel/power/snapshot.c > > @@ -76,6 +76,32 @@ static inline void hibernate_restore_protect_page(void *page_address) {} > > static inline void hibernate_restore_unprotect_page(void *page_address) {} > > #endif /* CONFIG_STRICT_KERNEL_RWX && CONFIG_ARCH_HAS_SET_MEMORY */ > > > > +static inline void hibernate_map_page(struct page *page, int enable) > > +{ > > + if (IS_ENABLED(CONFIG_ARCH_HAS_SET_DIRECT_MAP)) { > > + unsigned long addr = (unsigned long)page_address(page); > > + int ret; > > + > > + /* > > + * This should not fail because remapping a page here means > > + * that we only update protection bits in an existing PTE. > > + * It is still worth to have WARN_ON() here if something > > + * changes and this will no longer be the case. > > + */ > > + if (enable) > > + ret = set_direct_map_default_noflush(page); > > + else > > + ret = set_direct_map_invalid_noflush(page); > > + > > + if (WARN_ON(ret)) > > _ONCE? I've changed it to pr_warn() after David said people enable panic on warn in production kernels. > > + return; > > + > > + flush_tlb_kernel_range(addr, addr + PAGE_SIZE); > > + } else { > > + debug_pagealloc_map_pages(page, 1, enable); > > + } > > +} > > + > > static int swsusp_page_is_free(struct page *); > > static void swsusp_set_page_forbidden(struct page *); > > static void swsusp_unset_page_forbidden(struct page *); > > -- > Kirill A. Shutemov -- Sincerely yours, Mike.