From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 544FFC2D0A3 for ; Thu, 29 Oct 2020 07:56:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03C7320EDD for ; Thu, 29 Oct 2020 07:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603958178; bh=5V9raRTAO8xn/TWxASurP3gs711BOhAaxxP12fBIpug=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=uQ4GCCa49vwl+3LSo9Lsr+/FEIVtIYA1czgjpiwJ+rxUzkXj/M/aI3KZzMH3muUzi 9R2tPJsAfj21SFZMP/Q9iuHkB3srfLa92y0YV1KHg/ok2Cqyz5v29SV/c7AcgI7UPt JC5tA6YNxRGl4Gv1Qo23huBWLu+IpI5mbMzzmXWU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731722AbgJ2Hz4 (ORCPT ); Thu, 29 Oct 2020 03:55:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:56062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731531AbgJ2Hyb (ORCPT ); Thu, 29 Oct 2020 03:54:31 -0400 Received: from kernel.org (unknown [87.70.96.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E3F1620EDD; Thu, 29 Oct 2020 07:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603958070; bh=5V9raRTAO8xn/TWxASurP3gs711BOhAaxxP12fBIpug=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=smkJOo6ejvJldTmaaqqEFjGX6LWRb76WicHCvCBcrN9qOMMNByoTCZCyPYd8JouA6 FsHRDDeFim9xIzvbeq0FyT0w7eXPAkBTo6qZkKSqULTgH8mtDPy6sKAI1NlM6RXbk0 gkAxCVUoVSgKd/P/vRphpHr37cKvq2I6Usohfbtc= Date: Thu, 29 Oct 2020 09:54:16 +0200 From: Mike Rapoport To: "Edgecombe, Rick P" Cc: "akpm@linux-foundation.org" , "david@redhat.com" , "cl@linux.com" , "gor@linux.ibm.com" , "hpa@zytor.com" , "peterz@infradead.org" , "catalin.marinas@arm.com" , "dave.hansen@linux.intel.com" , "borntraeger@de.ibm.com" , "penberg@kernel.org" , "iamjoonsoo.kim@lge.com" , "linux-mm@kvack.org" , "will@kernel.org" , "aou@eecs.berkeley.edu" , "kirill@shutemov.name" , "rientjes@google.com" , "rppt@linux.ibm.com" , "paulus@samba.org" , "hca@linux.ibm.com" , "pavel@ucw.cz" , "bp@alien8.de" , "sparclinux@vger.kernel.org" , "mpe@ellerman.id.au" , "luto@kernel.org" , "davem@davemloft.net" , "tglx@linutronix.de" , "rjw@rjwysocki.net" , "linux-riscv@lists.infradead.org" , "benh@kernel.crashing.org" , "linuxppc-dev@lists.ozlabs.org" , "x86@kernel.org" , "linux-pm@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "palmer@dabbelt.com" , "Brown, Len" , "mingo@redhat.com" , "linux-s390@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "paul.walmsley@sifive.com" Subject: Re: [PATCH 2/4] PM: hibernate: improve robustness of mapping pages in the direct map Message-ID: <20201029075416.GJ1428094@kernel.org> References: <20201025101555.3057-1-rppt@kernel.org> <20201025101555.3057-3-rppt@kernel.org> <3b4b2b3559bd3dc68adcddf99415bae57152cb6b.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3b4b2b3559bd3dc68adcddf99415bae57152cb6b.camel@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Wed, Oct 28, 2020 at 09:15:38PM +0000, Edgecombe, Rick P wrote: > On Sun, 2020-10-25 at 12:15 +0200, Mike Rapoport wrote: > > + if (IS_ENABLED(CONFIG_ARCH_HAS_SET_DIRECT_MAP)) { > > + unsigned long addr = (unsigned > > long)page_address(page); > > + int ret; > > + > > + if (enable) > > + ret = set_direct_map_default_noflush(page); > > + else > > + ret = set_direct_map_invalid_noflush(page); > > + > > + if (WARN_ON(ret)) > > + return; > > + > > + flush_tlb_kernel_range(addr, addr + PAGE_SIZE); > > + } else { > > + debug_pagealloc_map_pages(page, 1, enable); > > + } > > Looking at the arm side again, I think this might actually introduce a > regression for the arm/hibernate/DEBUG_PAGEALLOC combo. > > Unlike __kernel_map_pages(), it looks like arm's cpa will always bail > in the set_direct_map_() functions if rodata_full is false. > > So if rodata_full was disabled but debug page alloc is on, then this > would now skip remapping the pages. I guess the significance depends > on whether hibernate could actually try to save any DEBUG_PAGEALLOC > unmapped pages. Looks like it to me though. __kernel_map_pages() on arm64 will also bail out if rodata_full is false: void __kernel_map_pages(struct page *page, int numpages, int enable) { if (!debug_pagealloc_enabled() && !rodata_full) return; set_memory_valid((unsigned long)page_address(page), numpages, enable); } So using set_direct_map() to map back pages removed from the direct map with __kernel_map_pages() seems safe to me. -- Sincerely yours, Mike. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01B5BC55179 for ; Thu, 29 Oct 2020 07:55:06 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B84220782 for ; Thu, 29 Oct 2020 07:55:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="i7nH9xLJ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="smkJOo6e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B84220782 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bnfdN/enTTY3DdYAKgEBEDzg/hDxGYLAPa/V7crPZ3E=; b=i7nH9xLJ3hLKvhjdZHxxQZicM OMfPXSRo5xnAJX21ePyEetDse+ZYozBVXjZg6eK+Y2lWMJnTiNB56fC+KRuHX3QrPg4qQuLtPqREE vyQ4k/o7Rfsu646KVTJv1vjN33Mi7SJjcRznc0JF4x1ftqOfxYMplCkHcrYw4KIXT1Gaa3Y5KNW9y JISXO//kU9uyle/HwPzWvwv5iOcZt9eL1IshpB8Z5QXSP8KfzLKLbOICMie0LQwuiO7Fer1BhrjCY I1IFFBlJCjvIsvV5o0mQ9RPUbkxqVWl66oqoc+hbXBR2KKTY7oouswEkyNTUReI78ZhYVKXEIAnmS Ui8BwdJ5w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY2lm-0002ik-Kc; Thu, 29 Oct 2020 07:54:50 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY2lT-0002ae-S4; Thu, 29 Oct 2020 07:54:33 +0000 Received: from kernel.org (unknown [87.70.96.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E3F1620EDD; Thu, 29 Oct 2020 07:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603958070; bh=5V9raRTAO8xn/TWxASurP3gs711BOhAaxxP12fBIpug=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=smkJOo6ejvJldTmaaqqEFjGX6LWRb76WicHCvCBcrN9qOMMNByoTCZCyPYd8JouA6 FsHRDDeFim9xIzvbeq0FyT0w7eXPAkBTo6qZkKSqULTgH8mtDPy6sKAI1NlM6RXbk0 gkAxCVUoVSgKd/P/vRphpHr37cKvq2I6Usohfbtc= Date: Thu, 29 Oct 2020 09:54:16 +0200 From: Mike Rapoport To: "Edgecombe, Rick P" Subject: Re: [PATCH 2/4] PM: hibernate: improve robustness of mapping pages in the direct map Message-ID: <20201029075416.GJ1428094@kernel.org> References: <20201025101555.3057-1-rppt@kernel.org> <20201025101555.3057-3-rppt@kernel.org> <3b4b2b3559bd3dc68adcddf99415bae57152cb6b.camel@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <3b4b2b3559bd3dc68adcddf99415bae57152cb6b.camel@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201029_035432_244094_8E75DA5A X-CRM114-Status: GOOD ( 18.14 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "benh@kernel.crashing.org" , "david@redhat.com" , "peterz@infradead.org" , "catalin.marinas@arm.com" , "dave.hansen@linux.intel.com" , "linux-mm@kvack.org" , "paulus@samba.org" , "pavel@ucw.cz" , "hpa@zytor.com" , "sparclinux@vger.kernel.org" , "cl@linux.com" , "will@kernel.org" , "linux-riscv@lists.infradead.org" , "linux-s390@vger.kernel.org" , "mpe@ellerman.id.au" , "x86@kernel.org" , "rppt@linux.ibm.com" , "borntraeger@de.ibm.com" , "mingo@redhat.com" , "rientjes@google.com" , "Brown, Len" , "aou@eecs.berkeley.edu" , "gor@linux.ibm.com" , "linux-pm@vger.kernel.org" , "hca@linux.ibm.com" , "bp@alien8.de" , "luto@kernel.org" , "paul.walmsley@sifive.com" , "kirill@shutemov.name" , "tglx@linutronix.de" , "akpm@linux-foundation.org" , "linux-arm-kernel@lists.infradead.org" , "rjw@rjwysocki.net" , "linux-kernel@vger.kernel.org" , "penberg@kernel.org" , "palmer@dabbelt.com" , "iamjoonsoo.kim@lge.com" , "linuxppc-dev@lists.ozlabs.org" , "davem@davemloft.net" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Wed, Oct 28, 2020 at 09:15:38PM +0000, Edgecombe, Rick P wrote: > On Sun, 2020-10-25 at 12:15 +0200, Mike Rapoport wrote: > > + if (IS_ENABLED(CONFIG_ARCH_HAS_SET_DIRECT_MAP)) { > > + unsigned long addr = (unsigned > > long)page_address(page); > > + int ret; > > + > > + if (enable) > > + ret = set_direct_map_default_noflush(page); > > + else > > + ret = set_direct_map_invalid_noflush(page); > > + > > + if (WARN_ON(ret)) > > + return; > > + > > + flush_tlb_kernel_range(addr, addr + PAGE_SIZE); > > + } else { > > + debug_pagealloc_map_pages(page, 1, enable); > > + } > > Looking at the arm side again, I think this might actually introduce a > regression for the arm/hibernate/DEBUG_PAGEALLOC combo. > > Unlike __kernel_map_pages(), it looks like arm's cpa will always bail > in the set_direct_map_() functions if rodata_full is false. > > So if rodata_full was disabled but debug page alloc is on, then this > would now skip remapping the pages. I guess the significance depends > on whether hibernate could actually try to save any DEBUG_PAGEALLOC > unmapped pages. Looks like it to me though. __kernel_map_pages() on arm64 will also bail out if rodata_full is false: void __kernel_map_pages(struct page *page, int numpages, int enable) { if (!debug_pagealloc_enabled() && !rodata_full) return; set_memory_valid((unsigned long)page_address(page), numpages, enable); } So using set_direct_map() to map back pages removed from the direct map with __kernel_map_pages() seems safe to me. -- Sincerely yours, Mike. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F125FC56202 for ; Thu, 29 Oct 2020 07:56:58 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EBBD820782 for ; Thu, 29 Oct 2020 07:56:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="smkJOo6e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBBD820782 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4CMHpF6S4SzDqXN for ; Thu, 29 Oct 2020 18:56:53 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=198.145.29.99; helo=mail.kernel.org; envelope-from=rppt@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=default header.b=smkJOo6e; dkim-atps=neutral Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4CMHlY66yVzDqGY for ; Thu, 29 Oct 2020 18:54:33 +1100 (AEDT) Received: from kernel.org (unknown [87.70.96.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E3F1620EDD; Thu, 29 Oct 2020 07:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603958070; bh=5V9raRTAO8xn/TWxASurP3gs711BOhAaxxP12fBIpug=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=smkJOo6ejvJldTmaaqqEFjGX6LWRb76WicHCvCBcrN9qOMMNByoTCZCyPYd8JouA6 FsHRDDeFim9xIzvbeq0FyT0w7eXPAkBTo6qZkKSqULTgH8mtDPy6sKAI1NlM6RXbk0 gkAxCVUoVSgKd/P/vRphpHr37cKvq2I6Usohfbtc= Date: Thu, 29 Oct 2020 09:54:16 +0200 From: Mike Rapoport To: "Edgecombe, Rick P" Subject: Re: [PATCH 2/4] PM: hibernate: improve robustness of mapping pages in the direct map Message-ID: <20201029075416.GJ1428094@kernel.org> References: <20201025101555.3057-1-rppt@kernel.org> <20201025101555.3057-3-rppt@kernel.org> <3b4b2b3559bd3dc68adcddf99415bae57152cb6b.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3b4b2b3559bd3dc68adcddf99415bae57152cb6b.camel@intel.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "david@redhat.com" , "peterz@infradead.org" , "catalin.marinas@arm.com" , "dave.hansen@linux.intel.com" , "linux-mm@kvack.org" , "paulus@samba.org" , "pavel@ucw.cz" , "hpa@zytor.com" , "sparclinux@vger.kernel.org" , "cl@linux.com" , "will@kernel.org" , "linux-riscv@lists.infradead.org" , "linux-s390@vger.kernel.org" , "x86@kernel.org" , "rppt@linux.ibm.com" , "borntraeger@de.ibm.com" , "mingo@redhat.com" , "rientjes@google.com" , "Brown, Len" , "aou@eecs.berkeley.edu" , "gor@linux.ibm.com" , "linux-pm@vger.kernel.org" , "hca@linux.ibm.com" , "bp@alien8.de" , "luto@kernel.org" , "paul.walmsley@sifive.com" , "kirill@shutemov.name" , "tglx@linutronix.de" , "akpm@linux-foundation.org" , "linux-arm-kernel@lists.infradead.org" , "rjw@rjwysocki.net" , "linux-kernel@vger.kernel.org" , "penberg@kernel.org" , "palmer@dabbelt.com" , "iamjoonsoo.kim@lge.com" , "linuxppc-dev@lists.ozlabs.org" , "davem@davemloft.net" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Wed, Oct 28, 2020 at 09:15:38PM +0000, Edgecombe, Rick P wrote: > On Sun, 2020-10-25 at 12:15 +0200, Mike Rapoport wrote: > > + if (IS_ENABLED(CONFIG_ARCH_HAS_SET_DIRECT_MAP)) { > > + unsigned long addr = (unsigned > > long)page_address(page); > > + int ret; > > + > > + if (enable) > > + ret = set_direct_map_default_noflush(page); > > + else > > + ret = set_direct_map_invalid_noflush(page); > > + > > + if (WARN_ON(ret)) > > + return; > > + > > + flush_tlb_kernel_range(addr, addr + PAGE_SIZE); > > + } else { > > + debug_pagealloc_map_pages(page, 1, enable); > > + } > > Looking at the arm side again, I think this might actually introduce a > regression for the arm/hibernate/DEBUG_PAGEALLOC combo. > > Unlike __kernel_map_pages(), it looks like arm's cpa will always bail > in the set_direct_map_() functions if rodata_full is false. > > So if rodata_full was disabled but debug page alloc is on, then this > would now skip remapping the pages. I guess the significance depends > on whether hibernate could actually try to save any DEBUG_PAGEALLOC > unmapped pages. Looks like it to me though. __kernel_map_pages() on arm64 will also bail out if rodata_full is false: void __kernel_map_pages(struct page *page, int numpages, int enable) { if (!debug_pagealloc_enabled() && !rodata_full) return; set_memory_valid((unsigned long)page_address(page), numpages, enable); } So using set_direct_map() to map back pages removed from the direct map with __kernel_map_pages() seems safe to me. -- Sincerely yours, Mike. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Rapoport Date: Thu, 29 Oct 2020 07:54:16 +0000 Subject: Re: [PATCH 2/4] PM: hibernate: improve robustness of mapping pages in the direct map Message-Id: <20201029075416.GJ1428094@kernel.org> List-Id: References: <20201025101555.3057-1-rppt@kernel.org> <20201025101555.3057-3-rppt@kernel.org> <3b4b2b3559bd3dc68adcddf99415bae57152cb6b.camel@intel.com> In-Reply-To: <3b4b2b3559bd3dc68adcddf99415bae57152cb6b.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: "Edgecombe, Rick P" Cc: "benh@kernel.crashing.org" , "david@redhat.com" , "peterz@infradead.org" , "catalin.marinas@arm.com" , "dave.hansen@linux.intel.com" , "linux-mm@kvack.org" , "paulus@samba.org" , "pavel@ucw.cz" , "hpa@zytor.com" , "sparclinux@vger.kernel.org" , "cl@linux.com" , "will@kernel.org" , "linux-riscv@lists.infradead.org" , "linux-s390@vger.kernel.org" , "mpe@ellerman.id.au" , "x86@kernel.org" , "rppt@linux.ibm.com" , "borntraeger@de.ibm.com" , "mingo@redhat.com" , "rientjes@google.com" , "Brown, Len" , "aou@eecs.berkeley.edu" , "gor@linux.ibm.com" , "linux-pm@vger.kernel.org" , "hca@linux.ibm.com" , "bp@alien8.de" , "luto@kernel.org" , "paul.walmsley@sifive.com" , "kirill@shutemov.name" , "tglx@linutronix.de" , "akpm@linux-foundation.org" , "linux-arm-kernel@lists.infradead.org" , "rjw@rjwysocki.net" , "linux-kernel@vger.kernel.org" , "penberg@kernel.org" , "palmer@dabbelt.com" , "iamjoonsoo.kim@lge.com" , "linuxppc-dev@lists.ozlabs.org" , "davem@davemloft.net" On Wed, Oct 28, 2020 at 09:15:38PM +0000, Edgecombe, Rick P wrote: > On Sun, 2020-10-25 at 12:15 +0200, Mike Rapoport wrote: > > + if (IS_ENABLED(CONFIG_ARCH_HAS_SET_DIRECT_MAP)) { > > + unsigned long addr = (unsigned > > long)page_address(page); > > + int ret; > > + > > + if (enable) > > + ret = set_direct_map_default_noflush(page); > > + else > > + ret = set_direct_map_invalid_noflush(page); > > + > > + if (WARN_ON(ret)) > > + return; > > + > > + flush_tlb_kernel_range(addr, addr + PAGE_SIZE); > > + } else { > > + debug_pagealloc_map_pages(page, 1, enable); > > + } > > Looking at the arm side again, I think this might actually introduce a > regression for the arm/hibernate/DEBUG_PAGEALLOC combo. > > Unlike __kernel_map_pages(), it looks like arm's cpa will always bail > in the set_direct_map_() functions if rodata_full is false. > > So if rodata_full was disabled but debug page alloc is on, then this > would now skip remapping the pages. I guess the significance depends > on whether hibernate could actually try to save any DEBUG_PAGEALLOC > unmapped pages. Looks like it to me though. __kernel_map_pages() on arm64 will also bail out if rodata_full is false: void __kernel_map_pages(struct page *page, int numpages, int enable) { if (!debug_pagealloc_enabled() && !rodata_full) return; set_memory_valid((unsigned long)page_address(page), numpages, enable); } So using set_direct_map() to map back pages removed from the direct map with __kernel_map_pages() seems safe to me. -- Sincerely yours, Mike. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CB85C2D0A3 for ; Thu, 29 Oct 2020 07:55:18 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 10590214DB for ; Thu, 29 Oct 2020 07:55:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IJqLuK7/"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="smkJOo6e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 10590214DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fTKNO1Pv6orw8Df8G48EKHsMC5QoAQsnD2TBKN9Cais=; b=IJqLuK7/vBQT5Zyq6fBI6wGbY 2wBSG4ZbhTRURnfIhyWQFe2WVLN4IdO88aOWHmPwZaw+pZbYTaqCX0soo2oGhZTkktTp40NKJPprD eOGJqoXTW+wZ+wLIPsELtPW/6+jN5GSQQwnhXgjvJw5b7tD6hVOkvuqJF+x0oQV4txwv+UxRuDBPE J+cFI4SHx8qWLP5Uwbdzt5gRLAFV1YKt70cRtIJ/lXM+qosYxb+6JwH7zjTzekDiezZbpIbFRLnPz NSPs2nAWrizkLs2XHPeLXhLNHGug2ns8mslcMeXpnek+iWSikU4I2li4O7aazNucWlQvFua2CyutF jWmUj/jWg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY2lg-0002ew-4q; Thu, 29 Oct 2020 07:54:44 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY2lT-0002ae-S4; Thu, 29 Oct 2020 07:54:33 +0000 Received: from kernel.org (unknown [87.70.96.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E3F1620EDD; Thu, 29 Oct 2020 07:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603958070; bh=5V9raRTAO8xn/TWxASurP3gs711BOhAaxxP12fBIpug=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=smkJOo6ejvJldTmaaqqEFjGX6LWRb76WicHCvCBcrN9qOMMNByoTCZCyPYd8JouA6 FsHRDDeFim9xIzvbeq0FyT0w7eXPAkBTo6qZkKSqULTgH8mtDPy6sKAI1NlM6RXbk0 gkAxCVUoVSgKd/P/vRphpHr37cKvq2I6Usohfbtc= Date: Thu, 29 Oct 2020 09:54:16 +0200 From: Mike Rapoport To: "Edgecombe, Rick P" Subject: Re: [PATCH 2/4] PM: hibernate: improve robustness of mapping pages in the direct map Message-ID: <20201029075416.GJ1428094@kernel.org> References: <20201025101555.3057-1-rppt@kernel.org> <20201025101555.3057-3-rppt@kernel.org> <3b4b2b3559bd3dc68adcddf99415bae57152cb6b.camel@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <3b4b2b3559bd3dc68adcddf99415bae57152cb6b.camel@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201029_035432_244094_8E75DA5A X-CRM114-Status: GOOD ( 18.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "benh@kernel.crashing.org" , "david@redhat.com" , "peterz@infradead.org" , "catalin.marinas@arm.com" , "dave.hansen@linux.intel.com" , "linux-mm@kvack.org" , "paulus@samba.org" , "pavel@ucw.cz" , "hpa@zytor.com" , "sparclinux@vger.kernel.org" , "cl@linux.com" , "will@kernel.org" , "linux-riscv@lists.infradead.org" , "linux-s390@vger.kernel.org" , "mpe@ellerman.id.au" , "x86@kernel.org" , "rppt@linux.ibm.com" , "borntraeger@de.ibm.com" , "mingo@redhat.com" , "rientjes@google.com" , "Brown, Len" , "aou@eecs.berkeley.edu" , "gor@linux.ibm.com" , "linux-pm@vger.kernel.org" , "hca@linux.ibm.com" , "bp@alien8.de" , "luto@kernel.org" , "paul.walmsley@sifive.com" , "kirill@shutemov.name" , "tglx@linutronix.de" , "akpm@linux-foundation.org" , "linux-arm-kernel@lists.infradead.org" , "rjw@rjwysocki.net" , "linux-kernel@vger.kernel.org" , "penberg@kernel.org" , "palmer@dabbelt.com" , "iamjoonsoo.kim@lge.com" , "linuxppc-dev@lists.ozlabs.org" , "davem@davemloft.net" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Oct 28, 2020 at 09:15:38PM +0000, Edgecombe, Rick P wrote: > On Sun, 2020-10-25 at 12:15 +0200, Mike Rapoport wrote: > > + if (IS_ENABLED(CONFIG_ARCH_HAS_SET_DIRECT_MAP)) { > > + unsigned long addr = (unsigned > > long)page_address(page); > > + int ret; > > + > > + if (enable) > > + ret = set_direct_map_default_noflush(page); > > + else > > + ret = set_direct_map_invalid_noflush(page); > > + > > + if (WARN_ON(ret)) > > + return; > > + > > + flush_tlb_kernel_range(addr, addr + PAGE_SIZE); > > + } else { > > + debug_pagealloc_map_pages(page, 1, enable); > > + } > > Looking at the arm side again, I think this might actually introduce a > regression for the arm/hibernate/DEBUG_PAGEALLOC combo. > > Unlike __kernel_map_pages(), it looks like arm's cpa will always bail > in the set_direct_map_() functions if rodata_full is false. > > So if rodata_full was disabled but debug page alloc is on, then this > would now skip remapping the pages. I guess the significance depends > on whether hibernate could actually try to save any DEBUG_PAGEALLOC > unmapped pages. Looks like it to me though. __kernel_map_pages() on arm64 will also bail out if rodata_full is false: void __kernel_map_pages(struct page *page, int numpages, int enable) { if (!debug_pagealloc_enabled() && !rodata_full) return; set_memory_valid((unsigned long)page_address(page), numpages, enable); } So using set_direct_map() to map back pages removed from the direct map with __kernel_map_pages() seems safe to me. -- Sincerely yours, Mike. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel