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=-14.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 DC875C432BE for ; Thu, 26 Aug 2021 09:01:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6CD4860E77 for ; Thu, 26 Aug 2021 09:01:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6CD4860E77 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id ED8F18D0002; Thu, 26 Aug 2021 05:01:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E889E8D0001; Thu, 26 Aug 2021 05:01:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D77F18D0002; Thu, 26 Aug 2021 05:01:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0072.hostedemail.com [216.40.44.72]) by kanga.kvack.org (Postfix) with ESMTP id BD55E8D0001 for ; Thu, 26 Aug 2021 05:01:21 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4FE3D183956C5 for ; Thu, 26 Aug 2021 09:01:21 +0000 (UTC) X-FDA: 78516637962.05.00CAEFC Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf16.hostedemail.com (Postfix) with ESMTP id D033FF0000A3 for ; Thu, 26 Aug 2021 09:01:20 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 528EC1FE68; Thu, 26 Aug 2021 09:01:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1629968479; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MF/TJuRAvKBiF1bTYgTrqmcC4Of5Rz/lTIfmYnEXMDI=; b=v0ZLz0Rz2ALxh0kUgipMnzd5RLpUEXM3RDvwSz9uM/vyKLVebd3+dPBAnS/gLeCWOjSO6R llZ92bPijxKnOcKwFKXrAWoG+3T9NK8KdESeQmBqEIYDBDVDB8jKW4Cv/uLISXIgPklqlB whnwT4BNPD30L9mKcEBMAnszMkr2CvA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1629968479; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MF/TJuRAvKBiF1bTYgTrqmcC4Of5Rz/lTIfmYnEXMDI=; b=1GUVHARXd6ybTyl51Sv63Qu7DQ3VNBud1h5mnb+VAAvOBraJemlX3kjpJZVOB65Ft2cLuH Ji0JUb5dGsTQZ6DA== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 1C9FF13AA5; Thu, 26 Aug 2021 09:01:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id xGxRBl9YJ2EAFQAAGKfGzw (envelope-from ); Thu, 26 Aug 2021 09:01:19 +0000 Message-ID: Date: Thu, 26 Aug 2021 11:01:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.0.1 Subject: Re: [RFC PATCH 4/4] x86/mm: write protect (most) page tables Content-Language: en-US To: Mike Rapoport , Dave Hansen Cc: linux-mm@kvack.org, Andrew Morton , Andy Lutomirski , Dave Hansen , Ira Weiny , Kees Cook , Mike Rapoport , Peter Zijlstra , Rick Edgecombe , x86@kernel.org, linux-kernel@vger.kernel.org References: <20210823132513.15836-1-rppt@kernel.org> <20210823132513.15836-5-rppt@kernel.org> <1cccc2b6-8b5b-4aee-483d-f10e64a248a5@intel.com> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: D033FF0000A3 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=v0ZLz0Rz; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=1GUVHARX; dmarc=none; spf=pass (imf16.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Rspamd-Server: rspam01 X-Stat-Signature: dgay89bx8591hqpxtjo8otzn48mjqkbi X-HE-Tag: 1629968480-155656 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: On 8/26/21 10:02, Mike Rapoport wrote: > On Mon, Aug 23, 2021 at 04:50:10PM -0700, Dave Hansen wrote: >> On 8/23/21 6:25 AM, Mike Rapoport wrote: >> > void ___pte_free_tlb(struct mmu_gather *tlb, struct page *pte) >> > { >> > + enable_pgtable_write(page_address(pte)); >> > pgtable_pte_page_dtor(pte); >> > paravirt_release_pte(page_to_pfn(pte)); >> > paravirt_tlb_remove_table(tlb, pte); >> > @@ -69,6 +73,7 @@ void ___pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd) >> > #ifdef CONFIG_X86_PAE >> > tlb->need_flush_all = 1; >> > #endif >> > + enable_pgtable_write(pmd); >> > pgtable_pmd_page_dtor(page); >> > paravirt_tlb_remove_table(tlb, page); >> > } >> >> I'm also cringing a bit at hacking this into the page allocator. A >> *lot* of what you're trying to do with getting large allocations out and >> splitting them up is done very well today by the slab allocators. It >> might take some rearrangement of 'struct page' metadata to be more slab >> friendly, but it does seem like a close enough fit to warrant investigating. > > I thought more about using slab, but it seems to me the least suitable > option. The usecases at hand (page tables, secretmem, SEV/TDX) allocate in > page granularity and some of them use struct page metadata, so even its > rearrangement won't help. And adding support for 2M slabs to SLUB would be > quite intrusive. Agree, and there would be unnecessary memory overhead too, SLUB would be happy to cache a 2MB block on each CPU, etc. > I think that better options are moving such cache deeper into buddy or > using e.g. genalloc instead of a list to deal with higher order allocations. > > The choice between these two will mostly depend of the API selection, i.e. > a GFP flag or a dedicated alloc/free. Implementing on top of buddy seem still like the better option to me.