Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3757495pxv; Mon, 19 Jul 2021 08:05:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxz75WJJ4LNnAcTzU9v2Ci/SJUsoqF2TzkG+kA6yPmQGXq+DOPHgixmYL0onue10NuXfWJK X-Received: by 2002:a17:906:9c84:: with SMTP id fj4mr26825443ejc.274.1626707097997; Mon, 19 Jul 2021 08:04:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707097; cv=none; d=google.com; s=arc-20160816; b=BwHLt4qWsSB3i8MOCM+EiCSfkXQujBN7gYTWDTEiDLR12uGDBTnvc8W2fHpgrcbEus cobO37e3HcLxOcpILHZVHGCGuRkiZj8f9/5rdseWhMz3hX1VXAPKgD6b7wnyjsDnQfk7 uk8DP29zuYvo9pvr2u9wZ5XrZHZv66p+VPkKe5A8C0/nljeFgSGyysyPAT9+b75CWW80 DsLuvaVnSbI2nTCVwzvqQaIs+wUTQ/yl1oaB8uUL4SBsdKGTHXayo/FvFnZllacxEF7n wXKKBr81oBdFPqB9KY7bBQMoX4ZeMLrbQ1T4VGC1sLHNTi+Hmjln07lWLU4efK/PCxZ3 9ZAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fkm6LZnfTqp/BthOG3rjm7Ue6RagtTuSJN/PWuQRzpc=; b=zjUzvDZU6bJNlQo6o9lJMAiSrNx7PQcEjaoBhLROV+bjdBsnmUD5UlSvK5O9dhGQKm 9Q5oR3P2KUCP1z2fmhhZjNLBsrkH0b90QWthTwiBRevTSeWfsjm9MnGFIwEBLdF7kI0S QjymzYaGYa8HzrfR8hb+2S9GP+LPv7Zk9JfiJDeF2HA2V83AhnV0xZbtUB0MiHZP7Vbi SkYX44MVBiWb8rf7rw/HIArjLr+ykGpTlTMz7KyNUklzxH2FbijT63aYQ0JBrmZNbtcl Azp2Fx+CZoixYiqJ71zKNmFANIIwdDY/NA7abcJs+hg+lCTOpWVUG2CFeyjaS+edgxNW x53Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JovvpLcs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o1si21557238edr.440.2021.07.19.08.04.15; Mon, 19 Jul 2021 08:04:57 -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=@linuxfoundation.org header.s=korg header.b=JovvpLcs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242531AbhGSOUH (ORCPT + 99 others); Mon, 19 Jul 2021 10:20:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:53752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242331AbhGSOTB (ORCPT ); Mon, 19 Jul 2021 10:19:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 51A4F6113B; Mon, 19 Jul 2021 14:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626706780; bh=Nj0Udr4R71nGxE+aMr8O49t+TEjcRM2tKiepHUjqTXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JovvpLcsvDyBv+4PXmX8xtZWFCOjgvOdvWF6Q314DT1/hREYqTDZpeMwDEg3EcPAa vmGi1pZZwH0hgKiuH8cMyhbkjjVwGW/348dJ7h+RphLTIsNnmVHDRmm4CxQRbFu9aq 5PhfTJ+Eod1Bl1mnrc2QcsjqPG9OkxWHGEMFufE0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bibo Mao , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 4.4 095/188] hugetlb: clear huge pte during flush function on mips platform Date: Mon, 19 Jul 2021 16:51:19 +0200 Message-Id: <20210719144935.253764628@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144913.076563739@linuxfoundation.org> References: <20210719144913.076563739@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bibo Mao [ Upstream commit 33ae8f801ad8bec48e886d368739feb2816478f2 ] If multiple threads are accessing the same huge page at the same time, hugetlb_cow will be called if one thread write the COW huge page. And function huge_ptep_clear_flush is called to notify other threads to clear the huge pte tlb entry. The other threads clear the huge pte tlb entry and reload it from page table, the reload huge pte entry may be old. This patch fixes this issue on mips platform, and it clears huge pte entry before notifying other threads to flush current huge page entry, it is similar with other architectures. Signed-off-by: Bibo Mao Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- arch/mips/include/asm/hugetlb.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/mips/include/asm/hugetlb.h b/arch/mips/include/asm/hugetlb.h index 982bc0685330..4747a4694669 100644 --- a/arch/mips/include/asm/hugetlb.h +++ b/arch/mips/include/asm/hugetlb.h @@ -67,7 +67,13 @@ static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm, static inline void huge_ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) { - flush_tlb_page(vma, addr & huge_page_mask(hstate_vma(vma))); + /* + * clear the huge pte entry firstly, so that the other smp threads will + * not get old pte entry after finishing flush_tlb_page and before + * setting new huge pte entry + */ + huge_ptep_get_and_clear(vma->vm_mm, addr, ptep); + flush_tlb_page(vma, addr); } static inline int huge_pte_none(pte_t pte) -- 2.30.2