From patchwork Wed Mar 8 09:41:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 66130 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp236763wrd; Wed, 8 Mar 2023 01:52:48 -0800 (PST) X-Google-Smtp-Source: AK7set94kn6ix/n6/+ZI92muoX29zOTf7S17PDNy7eX8gQkP+Pb/UIsCDep/0k7k+ZO0pSjEGACq X-Received: by 2002:a17:907:8a0c:b0:87b:3d29:2982 with SMTP id sc12-20020a1709078a0c00b0087b3d292982mr22449060ejc.11.1678269168047; Wed, 08 Mar 2023 01:52:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678269168; cv=none; d=google.com; s=arc-20160816; b=goFk1QnZzrrSJ14pTTzp/RaLmaq2EtsYGL4gBfC+qP+EqKPblO5DiRpuM3JW9L9vWm QaQrHGjsRhRdYIC2BR5/Hgd4RPPPylajfqkLxslIFj4fcTKoXPadcqksVm4VGTMK8eHM iJAFrx4Kk99+ashJLzbxo/ZWgdOB3Fee/sjwe2Pu1gBjWirSJvPljyVP3noowX3V+M9a Yu0T2W60cx5T2I5am7oqmJpuwCEyK1HbHZ2jRKoNBp4EB1uEhB/CpQqmbIKWCmJ6Rczt 5mZUz12ZLcpfuH8Vn6z5BL/UxFdXIdDgQYu3tP85CEpizQ++M3P9xf+Avg2MErnnokW5 lhfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gMbdMo/pBqYIxP3tjUm5UhHWCZe8JSSf6Iu/9RrXzi8=; b=bsRSLO7fSSQgYZQK9maYd6pSzb+AvbDVADtNcyFl33S7bYzgO4YOooGKER85m8E666 A+LE+xAD3Yg46YYni0JlvVKa2Zh6rcOQUth4XXVV+N87Wit6NnFHSK8PzisOzHqrTO0K XHKeSgl2Fpi5cGB4CywxYPFk8D3gws/JQueSwRSqAiOB8gDiS2h1peo+wOHD7REmw8Ho BEHaNV01pFeQiVIxMs8OHfuI3vDvqJrzl10vZtDLMWIyqB+6MG6O8TOI9hxAemMxT36h 2icrOkAn6zlIarNk3jwd8LORqbwNRrZk1sfq/TzEn35n72d/iyFqmBXF8Z4KR5DfxrSC PaNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=leVKbWeo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gz10-20020a170906f2ca00b009076178f532si11885978ejb.911.2023.03.08.01.52.24; Wed, 08 Mar 2023 01:52:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=leVKbWeo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230180AbjCHJmT (ORCPT + 99 others); Wed, 8 Mar 2023 04:42:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230171AbjCHJmA (ORCPT ); Wed, 8 Mar 2023 04:42:00 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FA09B7185 for ; Wed, 8 Mar 2023 01:41:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3B119B81C0B for ; Wed, 8 Mar 2023 09:41:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80E84C433D2; Wed, 8 Mar 2023 09:41:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678268500; bh=FOZyjqFesuEnEwpUW1WYq+F0fxn2qMQwF+XDs3hZBQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=leVKbWeo/7qOftIstG5B9Wgf9MRXnwDGvaQUihQL6sWuanLYUQozOUwMx4mEYxlep SK+6GKBux58RzySSLw+ASPQ2LI0d6QdcBWHG4l2uuE9FqQyRWANesgRaYuCvprRtL2 994aEBWZuA/D8wD0+MLrSqO/8JSauc/E8A48GBC4UFCF0Mteg/IOFl9IH+v5CGnkmX 78RxsHHsDeqbtilOWnIuJihopZEwO+M4DIWXi6/YmWDg7iUB7fVn9xfYNiaJ5WWZ4p tvTaCpCyYZdmV2vKLa1pPMyu6s3qL5dgi4J4Ywy5j0orqUR0qA92pNM5IFhFjn/keq 6l9vE6tUdD9qw== From: Mike Rapoport To: linux-mm@kvack.org Cc: Andrew Morton , Dave Hansen , Mike Rapoport , Peter Zijlstra , Rick Edgecombe , Song Liu , Thomas Gleixner , Vlastimil Babka , linux-kernel@vger.kernel.org, x86@kernel.org Subject: [RFC PATCH 5/5] EXPERIMENTAL: mm/secretmem: use __GFP_UNMAPPED Date: Wed, 8 Mar 2023 11:41:06 +0200 Message-Id: <20230308094106.227365-6-rppt@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230308094106.227365-1-rppt@kernel.org> References: <20230308094106.227365-1-rppt@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759792771052504592?= X-GMAIL-MSGID: =?utf-8?q?1759792771052504592?= From: "Mike Rapoport (IBM)" Signed-off-by: Mike Rapoport (IBM) --- mm/secretmem.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/mm/secretmem.c b/mm/secretmem.c index 0b502625cd30..f66dfd16a0c3 100644 --- a/mm/secretmem.c +++ b/mm/secretmem.c @@ -53,7 +53,6 @@ static vm_fault_t secretmem_fault(struct vm_fault *vmf) struct inode *inode = file_inode(vmf->vma->vm_file); pgoff_t offset = vmf->pgoff; gfp_t gfp = vmf->gfp_mask; - unsigned long addr; struct page *page; vm_fault_t ret; int err; @@ -66,38 +65,22 @@ static vm_fault_t secretmem_fault(struct vm_fault *vmf) retry: page = find_lock_page(mapping, offset); if (!page) { - page = alloc_page(gfp | __GFP_ZERO); + page = alloc_page(gfp | __GFP_ZERO | __GFP_UNMAPPED); if (!page) { ret = VM_FAULT_OOM; goto out; } - err = set_direct_map_invalid_noflush(page); - if (err) { - put_page(page); - ret = vmf_error(err); - goto out; - } - __SetPageUptodate(page); err = add_to_page_cache_lru(page, mapping, offset, gfp); if (unlikely(err)) { put_page(page); - /* - * If a split of large page was required, it - * already happened when we marked the page invalid - * which guarantees that this call won't fail - */ - set_direct_map_default_noflush(page); if (err == -EEXIST) goto retry; ret = vmf_error(err); goto out; } - - addr = (unsigned long)page_address(page); - flush_tlb_kernel_range(addr, addr + PAGE_SIZE); } vmf->page = page; @@ -150,15 +133,8 @@ static int secretmem_migrate_folio(struct address_space *mapping, return -EBUSY; } -static void secretmem_free_folio(struct folio *folio) -{ - set_direct_map_default_noflush(&folio->page); - folio_zero_segment(folio, 0, folio_size(folio)); -} - const struct address_space_operations secretmem_aops = { .dirty_folio = noop_dirty_folio, - .free_folio = secretmem_free_folio, .migrate_folio = secretmem_migrate_folio, };