Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp244475pxb; Thu, 26 Aug 2021 02:02:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqH/IUwhNhzL8O65rYccJtikjG0YVtEwYgJy6euOo/oVEwgqoMp3qevGMfAlxZgq0YHj1K X-Received: by 2002:a5e:da44:: with SMTP id o4mr2216719iop.147.1629968564086; Thu, 26 Aug 2021 02:02:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629968564; cv=none; d=google.com; s=arc-20160816; b=Cmq7subLfeArUnJYq9k0CrK1I6bhHM0qd9X8CITSsh6/iTgOoXn6x6r402bMMntJjS W0r7VLD4mlAeNW3xWxOjlg95lEXBEG6K4LyWesnKnmy0uVtL/Y8Xpa5IqUTT0ySZlvCE ZPbo2nRP2q7rhAqn5o7guLklmKVTv56vk/o/mGaTRdHVXI5v3KTvOjv+iutATwjdFJ/m A5lYaXvkev8z/rmKQ1g2oUu8ONhwDE/mMSuh3FE/kc8dnCNA85tOl39vk+5ry4S16zj3 DDUjIwoJByL0lbzCHfp2OwqCy4YRJQSZy3Z0MKPw79mUBcp94eDtTi3w1AjsNdzZ41jZ Is+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=MF/TJuRAvKBiF1bTYgTrqmcC4Of5Rz/lTIfmYnEXMDI=; b=lMzamWiscD/3r+ivpQbNWsAeBzBz0S9Z+D1T4Lfotf7Z1tCRb0uAhpQmATAI7+9wTz 8LYHiUMq2WgqJ2sEwMo/o4ZduSBdLGp6mWmO+xvp3hyoX04+7lum7+R9aE32S/NhxBp8 MpA+ExyIKCLjbD/6akZSbhNnotCET1oJN/ivnEzx2xYkzawZzDn71vHUN8s05w6zaxvl BZGAl7umTqHPciWVQH0KZAmb1eZbwy0zSGgGWT4oMl++dWzoWeac8l/ZnV4OE4JmjFL2 WSdIEPgm15imrNKl5Pju1HXCITgqk5dAM2pzuhMsm1tbOi81LdZ3XbLILykZ0VPMmfoc 1NrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=v0ZLz0Rz; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id az39si2136708jab.112.2021.08.26.02.02.31; Thu, 26 Aug 2021 02:02:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=v0ZLz0Rz; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240576AbhHZJCH (ORCPT + 99 others); Thu, 26 Aug 2021 05:02:07 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47014 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232957AbhHZJCH (ORCPT ); Thu, 26 Aug 2021 05:02:07 -0400 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.