Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp638977pxv; Thu, 15 Jul 2021 12:10:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPQkChc+sRyZuCOJxYXZn2Bo/kXNxspLDqEG8JAK5+Gv6eDrf6FF1KfBTjYSCT/2ac+fJP X-Received: by 2002:aa7:d991:: with SMTP id u17mr9047788eds.240.1626376232060; Thu, 15 Jul 2021 12:10:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626376232; cv=none; d=google.com; s=arc-20160816; b=vANig5pXSbDOtWMHLFa5ylquDuyzT/WJlBElaDAC+6zp+qD1tQpTdq/8XPqk8KfQKJ T/GYFmtWFK+/f5Peck9NJ27JtMFfmGEkRXb/TjVsDbeqp23Pv4C1MtqE1LkupcabyMir tJzW9QUFc6UTCbBtzdG0T521GU+togovGqhOWzHU+B3kNPw91HTK8kJiOj75SEFuMYfM uhcOB2u/Fa7jibmpLphIZ9HSBxV0FL6UA1NDrx1RpBTMfilXhdBJ/AUFrnutTkoiKSKi Nwpl1GERwh7rRVIOozOXhr+AAzxp9/newLcwrCVOy4w2uZ3AJ5Gaxkq8NLmbUGFdlQ0w xPBw== 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=G1hpVFYax1ywbng+ONH68QiUj31Dmjoi9aeHo8S3Za8=; b=fSnDBPA69NivgdDF1P3m0ydTQd+6UU4C08v4sZZ17DJMaiOEjpfcBQZTl06yX3a9nD uy11ZORF51i7WXpl+FKmu4CsWUIv9z+NdT4bmtekxoTUCV4ca78yAhMjHoGEnHmVbht0 M/JoInakcHsJ4ET2yq81zXwBy+e0lQlTmEFPbBba/lB9RmFjsv+JF572p4dH/wwVzdMs R6GN3efwrMcr7QIslQx6enrVQCg1gKt9V29FDsrzj7goACS7aYBUzzHIO9cFA/tWY/7+ 5EkizpIdPtKbUY2UEWyr6cFHwGGLGjSwh9soQSqyQmm9U32GyI4P8FfqtxeZlhF1Uz7n //kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MpVJePY5; 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 v1si8387623edx.481.2021.07.15.12.10.09; Thu, 15 Jul 2021 12:10:32 -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=MpVJePY5; 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 S241195AbhGOTHy (ORCPT + 99 others); Thu, 15 Jul 2021 15:07:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:34230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242248AbhGOS5O (ORCPT ); Thu, 15 Jul 2021 14:57:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 598E2613DC; Thu, 15 Jul 2021 18:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375258; bh=swNqVe0z99ZqvzGEdEapp55al/zXzvnmMw+OPrrGzhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MpVJePY5kl82pcfUtOPbJYi4KBbeJblxN303uLcMWpfB8qW9CCAflu7aJ4AAYwpvD 04ZNeyvqt9G9kaVuXurhTnpeRtYIHR8xcY1i5VnEd3LqogqT2wB+TgRLA2CPC7Oxv2 xuZsV0GcdgTl3NxpXJlsMlID8bDfHd6uUePoPuH0= 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 5.12 012/242] hugetlb: clear huge pte during flush function on mips platform Date: Thu, 15 Jul 2021 20:36:14 +0200 Message-Id: <20210715182553.931931387@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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 10e3be870df7..c2144409c0c4 100644 --- a/arch/mips/include/asm/hugetlb.h +++ b/arch/mips/include/asm/hugetlb.h @@ -46,7 +46,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); } #define __HAVE_ARCH_HUGE_PTE_NONE -- 2.30.2