Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp370906ybh; Wed, 22 Jul 2020 02:47:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzM+JcYeRuvgAdFX1xLoj3lJm4rVawMjdLlbipbv56Bpip6oeWZLduyuGH6P4Y4HHDlb6w1 X-Received: by 2002:a50:ccc7:: with SMTP id b7mr31313626edj.9.1595411267991; Wed, 22 Jul 2020 02:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595411267; cv=none; d=google.com; s=arc-20160816; b=jIQ0o09hFJZ7+T8fF0mJxi6NQCoWvpGAzw+vza0W68o7CQ0HTI6ZapDOP5c5AAA7yI X24A4BTFnc7afR2CFCDhVb2DF7y1oIfx3aDSu0rSj09QeUQkvy2t8A2K1uJyCbh0aSnP RN+ZFIhmZ9dXKSnNjM+R4wsSzm4MhcP/hMHOd3ZDFZb5N4EjXqYQDKYYBSCrk9A0JMkQ j0OMWFN3vZ85lF1Ng/6xw52YYHNJzS9VRoWgwwcvstEAI7SpyWN9i3+hURoxw+K8BZ53 DW2KTwi16/vogZ5vbPJUAUdJRYNlhtSzPCDhKABU8gWB48pk3MMtX1DNdUmSWTkqcKpR UmbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yYo4IrrUPC/u5TNQyahS6XDyB7Q0g6/zk1H4elFCsEo=; b=OqSNWJrMm0qQVhAt2unWeai0vZc6sAPC3m/FcTGEE5x6JcBi0tOWJF4irLBV/2LUCI 7zgPaKeejabeOP4wvuUJK5tnMA5hyX0pHF7WwCZkDWa3vat/NPzYFOcGPAlb2MZ7VmMC y3KMi8qR3e8bsnKFftKL2AO8rbkCfvPR4VJyE7ZDGIGFEi8Xsib9bOzBVswTJkWptc9t zd8CPg+5uuxY/syp5B1YPbNkd/NhW+DU0YPnFL0X2iO4kMt85vlIo3DkSbz6xBu/nILI j85+86+HsPMUWnT0QMp7oxO9A4Wqt4/jv6gsND8EnXqy2N5+XTxkO+TI+Uatj6Kb45mq OW7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KKZqApvR; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d21si13345826eje.437.2020.07.22.02.47.25; Wed, 22 Jul 2020 02:47:47 -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=@redhat.com header.s=mimecast20190719 header.b=KKZqApvR; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731850AbgGVJqb (ORCPT + 99 others); Wed, 22 Jul 2020 05:46:31 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:32401 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731680AbgGVJqW (ORCPT ); Wed, 22 Jul 2020 05:46:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595411180; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yYo4IrrUPC/u5TNQyahS6XDyB7Q0g6/zk1H4elFCsEo=; b=KKZqApvRXgufWtFML4lVttCx39ZWsxQe56lOALpagSNFEiKKiD+pYt1LYpwfE68P1r+UKY suTeD/cE8gDrJnLUvG29lo6Yi/+ZLNXntAtfNKlficNCmrsmSzRaid1DdjOIJKzRZ1Uy+I DZEIMJscgI16hqMHj2Yh+kL+jgTq0vs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-109-GIIpnbHlOd-59SCO_E-BiA-1; Wed, 22 Jul 2020 05:46:18 -0400 X-MC-Unique: GIIpnbHlOd-59SCO_E-BiA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 61D85100AA24; Wed, 22 Jul 2020 09:46:16 +0000 (UTC) Received: from t480s.redhat.com (ovpn-113-254.ams2.redhat.com [10.36.113.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFDA45D9CA; Wed, 22 Jul 2020 09:46:14 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-s390@vger.kernel.org, linux-mm@kvack.org, David Hildenbrand , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Gerald Schaefer Subject: [PATCH v2 5/9] s390/vmemmap: take the vmem_mutex when populating/freeing Date: Wed, 22 Jul 2020 11:45:54 +0200 Message-Id: <20200722094558.9828-6-david@redhat.com> In-Reply-To: <20200722094558.9828-1-david@redhat.com> References: <20200722094558.9828-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let's synchronize all accesses to the 1:1 and vmemmap mappings. This will be especially relevant when wanting to cleanup empty page tables that could be shared by both. Avoid races when removing tables that might be just about to get reused. Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Christian Borntraeger Cc: Gerald Schaefer Signed-off-by: David Hildenbrand --- arch/s390/mm/vmem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c index be32a38bb91fd..a2b79681df69d 100644 --- a/arch/s390/mm/vmem.c +++ b/arch/s390/mm/vmem.c @@ -334,17 +334,21 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, { int ret; + mutex_lock(&vmem_mutex); /* We don't care about the node, just use NUMA_NO_NODE on allocations */ ret = add_pagetable(start, end, false); if (ret) remove_pagetable(start, end, false); + mutex_unlock(&vmem_mutex); return ret; } void vmemmap_free(unsigned long start, unsigned long end, struct vmem_altmap *altmap) { + mutex_lock(&vmem_mutex); remove_pagetable(start, end, false); + mutex_unlock(&vmem_mutex); } void vmem_remove_mapping(unsigned long start, unsigned long size) -- 2.26.2