Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5609445ybl; Tue, 27 Aug 2019 07:14:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVW1tVBm79NaFQjjEyYBFefM9Xg2PttQdL+IPIEaKUv/uQu5nYzy4KIUuooMKfAwctGMeT X-Received: by 2002:a63:593:: with SMTP id 141mr21042117pgf.78.1566915263140; Tue, 27 Aug 2019 07:14:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566915263; cv=none; d=google.com; s=arc-20160816; b=0/ItcLGXfPBT78ZAq6/POBEXhbU92m81KciFAEc9JYEqlVrru514tJdoXpVk1b+6q0 I2f45XNjN25ywcF0d1MYbxrlGc2cYTnQsS75JODkXVCJ306Esqby4b39iPlvPjx4JFms CjZlMWeNI0ovlBE4g71SP//fZUP3dtzEuAV+JPApYHHcEZEmJqErLapD1z4y/8nchp1F omSGBktq73IuFZg+RRO8hHkMR8MOTXbUU7jLcgTdFfhikv6W8Q6WmZ7m/nbkj32QPagE 0HIRWoV+OnTFIgxbUKbkTCO2MkbK1kHTvM+PTq9taMfoQ3p1LojVeU4wbPjv+r+kmuQf YZiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date; bh=ByLglzaozDtM5I9bARQAsZ1ivZpnW3zcFzTrBPy7dn0=; b=t9B5sM1pppLWXMHeXXoNEKrbFKSCzHI8xQMeuKue7LhX0ylEFDxlKFAIs0anCC7Ii3 PBffMxq/3KWblUGGDT7iz0ePpC7aLx2ZCQZHByuvQa9A+926C6Ugk97Dx8mlt/X/S39Y ksh/8bcgazysJRn3vdtRrCT9M4xw1Bgla2uNihEfoAySOR+zyGE8CEC16jsxOFK+7mBS 41Ma9jGvER6DfzTK+dsYxq9AowCznyGLLw/szlrkTPTrlHso+GNo8oRWe4iXhF/sLY/o sVeQ+5X0fXLnrIXa8PZxrlWh69O2cThdC+aS/4gYND8ZI48a7gPNYoRtM2UFVv/aDM67 zbUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4si13169129pli.229.2019.08.27.07.14.08; Tue, 27 Aug 2019 07:14:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729749AbfH0OLl (ORCPT + 99 others); Tue, 27 Aug 2019 10:11:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57856 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbfH0OLk (ORCPT ); Tue, 27 Aug 2019 10:11:40 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 63E8118C892F; Tue, 27 Aug 2019 14:11:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4D9555D712; Tue, 27 Aug 2019 14:11:40 +0000 (UTC) Received: from zmail17.collab.prod.int.phx2.redhat.com (zmail17.collab.prod.int.phx2.redhat.com [10.5.83.19]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2AFAE18089C8; Tue, 27 Aug 2019 14:11:40 +0000 (UTC) Date: Tue, 27 Aug 2019 10:11:39 -0400 (EDT) From: Jan Stancek To: Sasha Levin Cc: peterz@infradead.org, will@kernel.org, stable@vger.kernel.org, torvalds@linux-foundation.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, Waiman Long , dbueso@suse.de, Ingo Molnar , Jan Stancek Message-ID: <396661303.8419298.1566915099958.JavaMail.zimbra@redhat.com> In-Reply-To: <20190826143114.23471-1-sashal@kernel.org> References: <20190826143114.23471-1-sashal@kernel.org> Subject: Re: [PATCH v5.2 1/2] locking/rwsem: Add missing ACQUIRE to read_slowpath exit when queue is empty MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.40.204.166, 10.4.195.12] Thread-Topic: locking/rwsem: Add missing ACQUIRE to read_slowpath exit when queue is empty Thread-Index: pM7Z1VrNvE4gMqpOiVyEBizAqOeMqQ== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Tue, 27 Aug 2019 14:11:40 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- Original Message ----- > From: Jan Stancek > > [ Upstream commit e1b98fa316648420d0434d9ff5b92ad6609ba6c3 ] > > LTP mtest06 has been observed to occasionally hit "still mapped when > deleted" and following BUG_ON on arm64. > > The extra mapcount originated from pagefault handler, which handled > pagefault for vma that has already been detached. vma is detached > under mmap_sem write lock by detach_vmas_to_be_unmapped(), which > also invalidates vmacache. > > When the pagefault handler (under mmap_sem read lock) calls > find_vma(), vmacache_valid() wrongly reports vmacache as valid. > > After rwsem down_read() returns via 'queue empty' path (as of v5.2), > it does so without an ACQUIRE on sem->count: > > down_read() > __down_read() > rwsem_down_read_failed() > __rwsem_down_read_failed_common() > raw_spin_lock_irq(&sem->wait_lock); > if (list_empty(&sem->wait_list)) { > if (atomic_long_read(&sem->count) >= 0) { > raw_spin_unlock_irq(&sem->wait_lock); > return sem; > > The problem can be reproduced by running LTP mtest06 in a loop and > building the kernel (-j $NCPUS) in parallel. It does reproduces since > v4.20 on arm64 HPE Apollo 70 (224 CPUs, 256GB RAM, 2 nodes). It > triggers reliably in about an hour. > > The patched kernel ran fine for 10+ hours. > > Signed-off-by: Jan Stancek > Signed-off-by: Peter Zijlstra (Intel) > Reviewed-by: Will Deacon > Acked-by: Waiman Long > Cc: Linus Torvalds > Cc: Peter Zijlstra > Cc: Thomas Gleixner > Cc: dbueso@suse.de > Fixes: 4b486b535c33 ("locking/rwsem: Exit read lock slowpath if queue empty & > no writer") > Link: > https://lkml.kernel.org/r/50b8914e20d1d62bb2dee42d342836c2c16ebee7.1563438048.git.jstancek@redhat.com > Signed-off-by: Ingo Molnar > Signed-off-by: Sasha Levin > --- > > This is a backport for the v5.2 stable tree. There were multiple reports > of this issue being hit. > > Given that there were a few changes to the code around this, I'd > appreciate an ack before pulling it in. ACK, both look good to me. I also re-ran reproducer with this series applied on top of 5.2.10, it PASS-ed. Thanks, Jan