Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2880716rdh; Mon, 30 Oct 2023 10:13:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEodRL/06Vu5o1q5YUgKOoU/jWwdhHlGoY63aKUclqZy+7A8aRyjXiT0iww1swfZo6hxMuA X-Received: by 2002:a17:90a:f0d8:b0:274:4e9b:7a1a with SMTP id fa24-20020a17090af0d800b002744e9b7a1amr7240632pjb.44.1698685984748; Mon, 30 Oct 2023 10:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698685984; cv=none; d=google.com; s=arc-20160816; b=oTFUxSUko+deGk2AfMOdQxd/QU4PxAzXbTIKodijxrOOdr6k8epcdkjegBCS1WyTMn KuOqNQXFU0Fh3gF8/64Mq+ac8dUcY+VJjNo14bw1UqJckZe10qU3FYg5y0JHXn175rmh Rfj6t+yqXFHzCnOXqgvqAexcfpoEw0YrvNhWqWoYBGPG/fmUgDYq+UV18N9B8eHBtJM6 imd14coP/54FhyCs/jHD5xZ92NLqCBINYM9/yM91lunvJqGuIwscZ/WjOtpnzwRk+zew VE1P3Afw3FP5KB2HMX4qmvDC3AS5X/9w+bcw3/FSZV/BG4YbId7s6uOUn4MnE73zEM2i oQaw== 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:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=lo4ysHz5pmHfFsXnk84EoayTJ3hTlIhc3rVOfp1rxtc=; fh=9GjpMzJz+uuhn19uB36EwSK3xE6lNesC+Xo4sskdlZ8=; b=fu0X8pi6QsaQk8nFiL3kTae/44OPnnaGtRcwWmmBv2CTPyH9Up8fds5vOxWMSRbE0T 796XVRpDaZg5DNG5thnRBfYDGBppda2Ellp3/8DwIkst1CIjt3MNJbhU+o+ViqVsYjtq wILByF4aV3PkVMGmrhTx0AMZc859BJCxkCec9OueSJeGTkBZKapobmm31+NULmkibVSb 6HHXk3Fek4Hf7HojMm4J8I8AUva/swNgl767qyXMQTZLNpuzGf80CimsJ1JZbvGoxjFV xVPBA7eHYyUfA6C5rEYvk4rrjKWuaJIAUIsTZy5lOVJUwI8++qsoLdoIJfF8GLfELda9 HwSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cpLDJt2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id q92-20020a17090a756500b002534f4ce2b6si6270782pjk.125.2023.10.30.10.13.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 10:13:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cpLDJt2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 3414F80491C1; Mon, 30 Oct 2023 10:13:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233739AbjJ3RM4 (ORCPT + 99 others); Mon, 30 Oct 2023 13:12:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232579AbjJ3RMy (ORCPT ); Mon, 30 Oct 2023 13:12:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B133103 for ; Mon, 30 Oct 2023 10:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698685915; h=from:from:reply-to:subject:subject: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:autocrypt:autocrypt; bh=lo4ysHz5pmHfFsXnk84EoayTJ3hTlIhc3rVOfp1rxtc=; b=cpLDJt2+6yxkZbmC7dAvXetuv6zb+Okf2WZrlidRuXr59dd4Ieo0D95vLh1pG3XpMitwSH FIYEosZk7PEEkIiKFempJUazAQzvBf4NHCnThG1GmfPYeV/D6LBQVQBFS6toBJtoXUnkfc xAd4JF24ptyQSHh5Q3SK3zFHgkxwjko= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-211-kRtekgbKNqmBJLwiSZ_Caw-1; Mon, 30 Oct 2023 13:11:54 -0400 X-MC-Unique: kRtekgbKNqmBJLwiSZ_Caw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4084163ecd9so34499675e9.3 for ; Mon, 30 Oct 2023 10:11:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698685913; x=1699290713; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lo4ysHz5pmHfFsXnk84EoayTJ3hTlIhc3rVOfp1rxtc=; b=h51Z6YuK8P8YYd+N7tchSU2cHfxdsEhPj6Knti/XF1XISNtalheSI9bKX6hM6pNxLv DMr0vp0NewFkNpxPUK2rnvf3I/3SVgPM4kVc5Ifbojf/rJB1LvVu18axezw/K+FgL3eN IjjrxIapxWFitI3cumovqB/SkDpxPskZPVMZrQiYNEAJvvtR5EdQrlO1YKlypwdPd5qo Dywjmh3C777qPGPRWnD10GK+FUzGG5rRb/56SK9/qKhMNqpwNpNC/s+vTJwOPikfDj54 cP+Mdi4ICCj/dKRpuA015W8S7uJs4wK82ceLmngYIGVNjV7xxk5lgKcYu5Cz8g+f5WBL EK3w== X-Gm-Message-State: AOJu0Yx14YPV5W4mnJD+NFVmXmiabpTIllo03Hwowmxd84k6jsehveo0 wwDKgdw4wvkiWwyitMwqy1fP6nEsMGVxtljUDz0eA1dRanTDrvnLNKdZExk5QXrjIRYkDVr7VWi 4y2jFOtkloocfZShGNxS19Bzr X-Received: by 2002:a05:600c:1c9a:b0:401:d803:6243 with SMTP id k26-20020a05600c1c9a00b00401d8036243mr8797117wms.32.1698685912903; Mon, 30 Oct 2023 10:11:52 -0700 (PDT) X-Received: by 2002:a05:600c:1c9a:b0:401:d803:6243 with SMTP id k26-20020a05600c1c9a00b00401d8036243mr8797063wms.32.1698685912474; Mon, 30 Oct 2023 10:11:52 -0700 (PDT) Received: from [192.168.1.174] ([151.81.68.207]) by smtp.googlemail.com with ESMTPSA id w16-20020adfcd10000000b0032da75af3easm8617198wrm.80.2023.10.30.10.11.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Oct 2023 10:11:51 -0700 (PDT) Message-ID: <773328b3-0ef0-4e93-afb9-6fba3302b8a7@redhat.com> Date: Mon, 30 Oct 2023 18:11:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v13 10/35] KVM: Add a dedicated mmu_notifier flag for reclaiming freed memory Content-Language: en-US To: Sean Christopherson , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Viro , Christian Brauner , "Matthew Wilcox (Oracle)" , Andrew Morton Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Xu Yilun , Chao Peng , Fuad Tabba , Jarkko Sakkinen , Anish Moorthy , David Matlack , Yu Zhang , Isaku Yamahata , =?UTF-8?B?TWlja2HDq2wgU2FsYcO8?= =?UTF-8?Q?n?= , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-11-seanjc@google.com> From: Paolo Bonzini Autocrypt: addr=pbonzini@redhat.com; keydata= xsEhBFRCcBIBDqDGsz4K0zZun3jh+U6Z9wNGLKQ0kSFyjN38gMqU1SfP+TUNQepFHb/Gc0E2 CxXPkIBTvYY+ZPkoTh5xF9oS1jqI8iRLzouzF8yXs3QjQIZ2SfuCxSVwlV65jotcjD2FTN04 hVopm9llFijNZpVIOGUTqzM4U55sdsCcZUluWM6x4HSOdw5F5Utxfp1wOjD/v92Lrax0hjiX DResHSt48q+8FrZzY+AUbkUS+Jm34qjswdrgsC5uxeVcLkBgWLmov2kMaMROT0YmFY6A3m1S P/kXmHDXxhe23gKb3dgwxUTpENDBGcfEzrzilWueOeUWiOcWuFOed/C3SyijBx3Av/lbCsHU Vx6pMycNTdzU1BuAroB+Y3mNEuW56Yd44jlInzG2UOwt9XjjdKkJZ1g0P9dwptwLEgTEd3Fo UdhAQyRXGYO8oROiuh+RZ1lXp6AQ4ZjoyH8WL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B3shR+vMY3i3Ip0e41zKx0CvlAhMOo6otaHmcxr35sWq1Jk tLkbn3wG+fPQCVudJJECvVQ//UAthSSEklA50QtD2sBkmQ14ZryEyTHQ+E42K3j2IUmOLriF dNr9NvE1QGmGyIcbw2NIVEBOK/GWxkS5+dmxM2iD4Jdaf2nSn3jlHjEXoPwpMs0KZsgdU0pP JQzMUMwmB1wM8JxovFlPYrhNT9MAEQEAAcLBMwQYAQIACQUCVEJx7gIbDAAKCRB+FRAMzTZp sadRDqCctLmYICZu4GSnie4lKXl+HqlLanpVMOoFNnWs9oRP47MbE2wv8OaYh5pNR9VVgyhD OG0AU7oidG36OeUlrFDTfnPYYSF/mPCxHttosyt8O5kabxnIPv2URuAxDByz+iVbL+RjKaGM GDph56ZTswlx75nZVtIukqzLAQ5fa8OALSGum0cFi4ptZUOhDNz1onz61klD6z3MODi0sBZN Aj6guB2L/+2ZwElZEeRBERRd/uommlYuToAXfNRdUwrwl9gRMiA0WSyTb190zneRRDfpSK5d usXnM/O+kr3Dm+Ui+UioPf6wgbn3T0o6I5BhVhs4h4hWmIW7iNhPjX1iybXfmb1gAFfjtHfL xRUr64svXpyfJMScIQtBAm0ihWPltXkyITA92ngCmPdHa6M1hMh4RDX+Jf1fiWubzp1voAg0 JBrdmNZSQDz0iKmSrx8xkoXYfA3bgtFN8WJH2xgFL28XnqY4M6dLhJwV3z08tPSRqYFm4NMP dRsn0/7oymhneL8RthIvjDDQ5ktUjMe8LtHr70OZE/TT88qvEdhiIVUogHdo4qBrk41+gGQh b906Dudw5YhTJFU3nC6bbF2nrLlB4C/XSiH76ZvqzV0Z/cAMBo5NF/w= In-Reply-To: <20231027182217.3615211-11-seanjc@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 30 Oct 2023 10:13:02 -0700 (PDT) On 10/27/23 20:21, Sean Christopherson wrote: > Handle AMD SEV's kvm_arch_guest_memory_reclaimed() hook by having > __kvm_handle_hva_range() return whether or not an overlapping memslot > was found, i.e. mmu_lock was acquired. Using the .on_unlock() hook > works, but kvm_arch_guest_memory_reclaimed() needs to run after dropping > mmu_lock, which makes .on_lock() and .on_unlock() asymmetrical. > > Use a small struct to return the tuple of the notifier-specific return, > plus whether or not overlap was found. Because the iteration helpers are > __always_inlined, practically speaking, the struct will never actually be > returned from a function call (not to mention the size of the struct will > be two bytes in practice). Could have been split in two patches, but it's fine anyway. Reviewed-by: Paolo Bonzini Paolo