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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 872AAE71D21 for ; Fri, 29 Sep 2023 12:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GkIH4RPKBeo9U1O9YyhBGO+NADeQwbTK+M4PCcexg9Y=; b=VwE1CIdOcaj6Hl fgTDIWcunGaYPGUF4HFXoTmV/wl6myj81iKzMQKjzYBWXkQbfBjjn0PUp5hzGSIXuBBGVzOq+osrA e9Bd0ctY6C0mgOEkrpGSYwAD87hQo0mcy4kY6pCljfptsWAgT7ItsdJmqcLY4GqIu1aMKLPfj4OTp qpEHgZvrzMTHJnpyNEr2jl1svcDPqZ40+TeycCRN1Th/PROhLq8ponPuvlIXfrdVl5GmGRovB6tYY zGZNhF9z6PTCJ53TUhM1QAknt0xZKrQl0v1yfqN1SkydaysFtudWe7FhmiSqpJgKBgaNwJinWnZA3 aRPChefoOreC9ZmNBo0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qmCuA-007uRO-1X; Fri, 29 Sep 2023 12:47:38 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qmCu6-007uQZ-3C for linux-arm-kernel@lists.infradead.org; Fri, 29 Sep 2023 12:47:36 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4056ce55e7eso109973415e9.2 for ; Fri, 29 Sep 2023 05:47:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695991648; x=1696596448; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=B2Baqv/p94at+BEzxik746G5coKuSURMzwoefIjj1qM=; b=l3yz+v7ZbJWqpxyjalzSmlN2Twmg3h5UzDFiTggcstPsCCg/B/AukGzng743pY92qc dBZjMZ0xD3phcrxT8X7/u34fUdbMazXKs8c/8SNUZdGwzCcEZw4z0nPhYOg7qplXe+PG VR+1EJEGzNloY3631WSwDZDaDHcJRNvakZnA1DWTtBGovayfRxvrlMVzKtGZ32WclIRQ qyH7/kAQKaGWUQZIptxy/1a9zX7Wi9n+54PoxE/WcwdI+GbNuT1QJ64G3Mz1m2RMlVCu iIEjyIpH7CCRjUsYSUKX3nV69Dyvg86nRUEUmmASs1Eh2tkaDr7q1eS7//Iqwdd5t1C5 cTfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695991648; x=1696596448; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=B2Baqv/p94at+BEzxik746G5coKuSURMzwoefIjj1qM=; b=SwzS62rbSI/aTLpgGAcxQwuyvJQ+FfXetHWXZ9PkKG+A2EZoC9wa4E9KstYAzuEjZb IxY93E1uwMa4FfqlLJ5q7god2lkMIfJ7HqQcsBAoyjmFalUyMJyip11nJZRFB57/FISD mY5UAV4LqJ+rDGH+CV5ld92Cfnf2PC2cOcPrscmL27YSnQPk8B4Z5Bldc5M5wnjHxLsW 227IQQyvYWf8de4P+XO/zfo4alPWVmTH4DpmXTsBHVDloaauMQL4NjGO/cZ+gvk4DanJ w7x3yjo7n7BlNRdlqCBCbFgrcA4q42v3RpKKA2nl3E3htPOmpHvxWzZGIdAbkdehwrdF Gqww== X-Gm-Message-State: AOJu0YwUfbeealY0YPOfbm2DQsN98uLEjEGhHhKLjU5x51XO826tUHDi iIHoD4oJy59SHC7aIWh+9hspFNO0mUHkkkHii5H2iw== X-Google-Smtp-Source: AGHT+IGue8b8bEC+SI+KHA/m1EPo6RoKJXOOvZN4bJqOr64nXH/TGLkK2dooTdLn+rtWyPAgPI77XQ== X-Received: by 2002:a7b:c40f:0:b0:405:37bb:d942 with SMTP id k15-20020a7bc40f000000b0040537bbd942mr3771978wmi.4.1695991647554; Fri, 29 Sep 2023 05:47:27 -0700 (PDT) Received: from google.com (65.0.187.35.bc.googleusercontent.com. [35.187.0.65]) by smtp.gmail.com with ESMTPSA id n9-20020a05600c294900b00401c595fcc7sm1373481wmd.11.2023.09.29.05.47.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 05:47:26 -0700 (PDT) Date: Fri, 29 Sep 2023 13:47:23 +0100 From: Vincent Donnefort To: Gavin Shan Cc: maz@kernel.org, oliver.upton@linux.dev, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, will@kernel.org, willy@infradead.org Subject: Re: [PATCH v2 1/2] KVM: arm64: Do not transfer page refcount for THP adjustment Message-ID: References: <20230928173205.2826598-1-vdonnefort@google.com> <20230928173205.2826598-2-vdonnefort@google.com> <3a05f8a1-5759-8744-49eb-e975c5cf129c@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <3a05f8a1-5759-8744-49eb-e975c5cf129c@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230929_054735_067286_BBB7843B X-CRM114-Status: GOOD ( 24.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Sep 29, 2023 at 04:59:20PM +1000, Gavin Shan wrote: > On 9/29/23 03:32, Vincent Donnefort wrote: > > GUP affects a refcount common to all pages forming the THP. There is > > therefore no need to move the refcount from a tail to the head page. > > Under the hood it decrements and increments the same counter. > > > > Signed-off-by: Vincent Donnefort > > > > Reviewed-by: Gavin Shan > > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > > index 587a104f66c3..de5e5148ef5d 100644 > > --- a/arch/arm64/kvm/mmu.c > > +++ b/arch/arm64/kvm/mmu.c > > @@ -1295,28 +1295,8 @@ transparent_hugepage_adjust(struct kvm *kvm, struct kvm_memory_slot *memslot, > > if (sz < PMD_SIZE) > > return PAGE_SIZE; > > - /* > > - * The address we faulted on is backed by a transparent huge > > - * page. However, because we map the compound huge page and > > - * not the individual tail page, we need to transfer the > > - * refcount to the head page. We have to be careful that the > > - * THP doesn't start to split while we are adjusting the > > - * refcounts. > > - * > > - * We are sure this doesn't happen, because mmu_invalidate_retry > > - * was successful and we are holding the mmu_lock, so if this > > - * THP is trying to split, it will be blocked in the mmu > > - * notifier before touching any of the pages, specifically > > - * before being able to call __split_huge_page_refcount(). > > - * > > - * We can therefore safely transfer the refcount from PG_tail > > - * to PG_head and switch the pfn from a tail page to the head > > - * page accordingly. > > - */ > > *ipap &= PMD_MASK; > > - kvm_release_pfn_clean(pfn); > > pfn &= ~(PTRS_PER_PMD - 1); > > - get_page(pfn_to_page(pfn)); > > *pfnp = pfn; > > return PMD_SIZE; > > The local variable @pfn can be dropped either. I would like to keep it for the following patch: pfn_to_folio(pfn); > > *pfnp &= ~(PTRS_PER_PMD - 1); > > Thanks, > Gavin > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel