Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp527859imn; Wed, 3 Aug 2022 14:15:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR4z9JGFsIIoDf4c084y+Vn8yxQTQe6/75y4EKDfuSiZZWraRtsKVOZNVjOfgx12cBnDhl4t X-Received: by 2002:a17:903:41c1:b0:16f:68c:28 with SMTP id u1-20020a17090341c100b0016f068c0028mr9429193ple.74.1659561347976; Wed, 03 Aug 2022 14:15:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1659561347; cv=pass; d=google.com; s=arc-20160816; b=VN5Ap554T7c4g7JejK/4KO//4Is51SfSl65ChC0pJKYPOyBoBsXR7hDeBZtps0k/qF uBe5rbQ+1r/zIo2u0+8mN8B4StWmbcNQYyfu9kFqzIn0lK8Iq8F+RfCWJtwaXwTs15Pk UUviAMbs7yTLHQR8mshjOCAdII++l7OUGXuWU6n0fwVF1o7Kq+WkPR5l4b5/PyJ1KBs+ ATPk7uGA8+PCNzFJQUBXwk7HUyHBo39eT0j5i5JSjjiLGp8DwWfIGG6eJ3dJtEKmcgvv kBA3H4+DWTDoQuPRjVqsVrh7VnwkLLbc/wCHORcFOsXBKoSApCTg1qUyzzNjGxQx5H3n yezg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=BqdfyEq1ak1O4RW3eyqDgSxMAz7IaHeijbnLVlh3EFI=; b=hKF8IzW4dFWnvRWzhrJtU4LBv1r3yCohiPopqykxnMN92oqXK4OGrLMrRW71E69bFe brYs0ZDnU1LuReG/vo8KACe8OMaGYvKhQQgsiEl5A32DGwrZsCAMo6qf7WA0ThlCa6Ce wUQ0NGRrrLa+vAW00s7iiSvl8y/uhef83Q1QkPMMO3tBnWBdeLcOR+CaSEyjeTXj/WS9 tCLYI5HPnZ7CD8O0MbPifIP7nyUjDxXvR9qNfeULZz2hVxHWs+jayusbFN8r5hIa2z6S ufvg9zCqt3KqCP/JgviDfFgKNneYt8LKI9VveOZEmGIuO+rVbzjKklRT9TeJmIjkJdk1 4ixw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=1jZIMwK3; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p7-20020a056a000b4700b0052d45b66299si10384466pfo.312.2022.08.03.14.15.14; Wed, 03 Aug 2022 14:15:47 -0700 (PDT) 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=@amd.com header.s=selector1 header.b=1jZIMwK3; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238558AbiHCVDo (ORCPT + 99 others); Wed, 3 Aug 2022 17:03:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236280AbiHCVDn (ORCPT ); Wed, 3 Aug 2022 17:03:43 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2071.outbound.protection.outlook.com [40.107.223.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D2925C970 for ; Wed, 3 Aug 2022 14:03:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i6yWaiSwZYs/DidEJEGTjkmpNiDEvS3Zsy+fyLO0allxPTBw0ZSi+AmbW+Whjn7hKuJfOTkoFDgH3cS0SEIHavjAd5BapplnJF72FesvSbTQHYIQWYp1yrZGuzUZhyiG48tx+aIkBlBFHSz+p9jl3WrsOX7i4b1g2knlk1YV984QHKuh76L33EWRFt533Yp9CdG2afErjZXxkUzoB40kFCFjiZb8hRUn5vd1qCh9E0KCMv1/FZKSjTbFBHI4C5+8Jk1Je6rEf/BYAwpCqX8pk6j5kB2zkM8UXLKloU9hqnfVlPEFAg4oZ6zwSGB/iC8uTUX8b6RX9nL2KDRD7movOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BqdfyEq1ak1O4RW3eyqDgSxMAz7IaHeijbnLVlh3EFI=; b=bdUCLgkOhMJBezLa/A8hDAc7SquchVRJqjwn+y8d0C59x2ijPcG5tGD68APA2sOT91j+zsOLqrcpUuu/Xq0/aMghr6bFaqc/sy4TanqLJFY5O7stpV95INB5t+h1VPUE8EHA7vOEG9JlthCgN2XbXhYx1PgK2Vc3guZS2iLCDmVS4bvCMPo6Q3ZDkqlne63nbGh2obae+ccfkvJOgl3GSd2HDSmnbc+Y0Iq+/ZfgMngXP5c8lj6Vxk0HWpxgQCw4iTU6Fz2puTz+7ERDz0v4ePzodWzVQ6Dofm+RfHhK6qfsgw0gswX7tFz7ljYHhsGTdwpqhkZRqWXWzxAQ6Cs2ag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BqdfyEq1ak1O4RW3eyqDgSxMAz7IaHeijbnLVlh3EFI=; b=1jZIMwK3uFPScQeEifeJk8quSTvfPe0dD4BmwDfdSjEDyZz8Yk3aFT1U4lVPJfv5ozOwFkaUtsPB6OKJnI+HQxrPh7tREqXNuNsDcer/hpfeFyv3hkDVkkLemNdRkdB4PVbV/+jfs7eWPX1Srliv7dmSR8Ae8aVapP346+qLjm0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) by SJ0PR12MB6736.namprd12.prod.outlook.com (2603:10b6:a03:47a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Wed, 3 Aug 2022 21:03:39 +0000 Received: from DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::1dac:1301:78a3:c0d0]) by DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::1dac:1301:78a3:c0d0%4]) with mapi id 15.20.5482.016; Wed, 3 Aug 2022 21:03:39 +0000 Message-ID: <0eccea46-648d-ff70-dcc6-fdca88ff1234@amd.com> Date: Wed, 3 Aug 2022 16:03:35 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v1.1 1/2] x86/sev: Use per-CPU PSC structure in prep for unaccepted memory support Content-Language: en-US To: Dave Hansen , linux-kernel@vger.kernel.org, x86@kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "Kirill A. Shutemov" , "H. Peter Anvin" , Michael Roth , Joerg Roedel , Andy Lutomirski , Peter Zijlstra References: <1b50311c-448b-96aa-1d96-f4bfed409c1f@amd.com> <2a2adc3570ae9c24d03fff877c4fe79ed43605e0.1659550264.git.thomas.lendacky@amd.com> <9f47ed0f-99cc-a237-f09b-45291feffcd3@amd.com> From: Tom Lendacky In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: BL0PR05CA0003.namprd05.prod.outlook.com (2603:10b6:208:91::13) To DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d04896b-62ca-46c0-a527-08da7593a367 X-MS-TrafficTypeDiagnostic: SJ0PR12MB6736:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nHhS1WWRkxRjTFc1fzK44fpqp37mLO7e+1r92XAmVl0tLQzu+7gOo8JeP/4Yg+HaD4TJc7VFnZb49KA54hYnZaC828aE+yd6ZXJcwjt+ZcdkTcyZtiHXQZrbCKiqoak0cs1fVPGVr5tdAapx33EamZWJ4OEp3ptrgjHt1JUHrMBoctUtJgjdw+vi2tAMKoN1PlOmU4CLsF0nur+xYApPQ2GjV4xvp7Z/NxRbTZPxhiCY5paenTfsAgpbB7EJcb6EhdQaWnLZr2SUMXlLjdDiIQqsn+8VUke3brx2NJsKuAywvUkYiTHf4DSw3oeWGNAUPCxiv0ofX2YbO7gdM5gX1YOd+Fptrc17OJATNLuv3yHmYTsEo9c3ppnEPUfyeCaLj5sqZfmo5Lqn1VN5DzWPgzKSvZJbCP550eMXACbx2/YJNbCorYf84aF02nZAeYxFyb+MCb6JFU5EQ6+Q39ndKUJcBGcjCTaA0ODdl7GsAMhE4nzejC7HQCmlpYyQbFsBJY0OLY7npu34mLkvPRoAscJkVhWlBcrExGaNTJIh+Ms3Ae+m6BhZ+rnP6pdRJ+ps7qRTjEEU754jEUb6lrS0cDNNRA+s1DYz70ziLjmWGvUQSJPxagv3OuFoQkuSEcgTykRCWAGXf8XUjE2ZrJOeKchB5PJLpXsKdUkdiw4AZiXDl8W20RMUlEeZkC2qq8Pjjfrw4pmgO8MIj+4PH8mLC4L18IO9FECofw1Y9YMzgm2kPyGWmqoLrpTCjy91QGe6Z1NqRsnjoZmYMJeqz7ME7LkxpfhtBs3S/Bl8hA2ZYk0jJt+RK3JBJP6Z0RIc1uzqZxWvfz01TAmK58M+J83RLw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR12MB5229.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(376002)(366004)(346002)(136003)(39860400002)(6506007)(316002)(8936002)(4744005)(36756003)(31686004)(4326008)(478600001)(8676002)(5660300002)(54906003)(6486002)(66556008)(66476007)(66946007)(7416002)(2616005)(26005)(6666004)(6512007)(186003)(41300700001)(2906002)(53546011)(83380400001)(38100700002)(31696002)(86362001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QkxtNUpLM3d6T3BBU1k4Vm0xMW1ZVlVENTJuMmhkMmRHS3V6c0x2emJmR1NR?= =?utf-8?B?UTdOVDYvVGZBb2RhdnRMSjlYRUtCU0lwa040WVBtRUc0UHQzZGQ2UHBad2F4?= =?utf-8?B?K3Q5djBHblRic2trd3ljOElwT2JoNFp5Zjc5R01kcTdkR1JNdjUvcHQ0SURH?= =?utf-8?B?UTNnN25DT0hwTjdtaThFclhKWUVFSkR2NnNDSjhaVDBqM3pWb1VnNWVncE04?= =?utf-8?B?ZFlodEUzOUh4QVhySGpFMnVUSjVxdWV5UlNWd1FUMytBYm9jRGorNHhhMFND?=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CekhncTA1OVBuMStPUVEwZ01K?= =?utf-8?Q?V6AfIsX3zCzWjkzxGXBuH5+XH?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d04896b-62ca-46c0-a527-08da7593a367 X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5229.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2022 21:03:39.0342 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CgblsJKJ1NRtjGy4v2T5NhyGbpI+1l12MS6v4SRsnY7RmDk2gltvaW692CAJ2g4XNeIOAUT0H8t4pc6tyHNxQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6736 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 On 8/3/22 13:24, Dave Hansen wrote: > On 8/3/22 11:21, Tom Lendacky wrote: >>> Would it be simpler to just do a spin_trylock_irqsave()?  You fall back >>> to early_set_pages_state() whenever you can't acquire the lock. >> >> I was looking at that and can definitely go that route if this approach >> is preferred. > > I prefer it for sure. > > This whole iteration does look good to me versus the per-cpu version, so > I say go ahead with doing this for v2 once you wait a bit for any more > feedback. I'm still concerned about the whole spinlock and performance. What if I reduce the number of entries in the PSC structure to, say, 64, which reduces the size of the struct to 520 bytes. Any issue if that is put on the stack, instead? It definitely makes things less complicated and feels like a good compromise on the size vs the number of PSC VMGEXIT requests. Thanks, Tom