Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp519000iog; Fri, 17 Jun 2022 08:01:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t1DYAD/uOnWK6hGfvtz5rWwEVQ4DbqBTvfbhmYJdpFswT4lYKsefk/5tApdpxaACrZof7/ X-Received: by 2002:a17:907:7da2:b0:711:f36e:b855 with SMTP id oz34-20020a1709077da200b00711f36eb855mr9939093ejc.308.1655478072533; Fri, 17 Jun 2022 08:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655478072; cv=none; d=google.com; s=arc-20160816; b=RepZ6tnAxpUiCpWEqnMX/TmtD4Fb7h7nvWGi2tDzcMXajryt/jsgdp3QZBW4X5NXMA UudZ6iHTqI92lHWeo60+ywGVhBOTVYqSMa0WspfrJa6Xc6VPLrU+U2JAk0bRkuA/VRPA FAIauSFaACxSjQ9vnrmVkFURaYlN3UnBq5TtvZoX7LWcgQD/Ou1MpcbmThPkvbansRpQ +NkYtL6Ofcz5Ruc8pOYElTxR0KPi2Vyq2ZMnPZxn9LNbwVuZPoqwaFOcn6PQvWmEUCBV 0cVz/uTDGxjHMS5b5yDNFliQYw9sJ3RccrFneEjNYGzpQtngcGjVG+VynILocGRHJWDf ylMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=gAYVwqMN/CZe6fC+f9RsMLvHlUb8Q6jQz2uIGknDWoM=; b=Q1UJxC+jBqe4cmHBifvIs7owHbwThBY76cAXAiZkHPhz5C9fdwjTqmKPONOane2rKt YSuuAnjDb/c82lDrkjgU0pR+ocwdNCeskokG8AZ5DCONtGebeFHGuPTNSPEBPoH5OyNb 1NhIUuKYlCKiyqcA3djrGBHXmKeDDqT4IPHi67+FSiV8h/BB01aRk2TNjX/AaKhA8AAi oor02DesC2YHxZ/2Jq/hyKIhw9UfM1qP6R4EW633+Zoa+FMHGCcKI5fv0LUG4oH2T/YO z0fzpelAjwGYpVCm6j3xnu386NUfT3kvWLCp6Y6Ynw8G9L0WqzWITl6hOPYBSchQow1q zwVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SEwtLNpd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa13-20020a1709076d0d00b00706fe017e89si5691677ejc.880.2022.06.17.08.00.41; Fri, 17 Jun 2022 08:01:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SEwtLNpd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1381817AbiFQO3a (ORCPT + 99 others); Fri, 17 Jun 2022 10:29:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234468AbiFQO31 (ORCPT ); Fri, 17 Jun 2022 10:29:27 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 00EEF4B1FF for ; Fri, 17 Jun 2022 07:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655476164; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gAYVwqMN/CZe6fC+f9RsMLvHlUb8Q6jQz2uIGknDWoM=; b=SEwtLNpdrXbYew4TN+GBpOmDx75UUbxosmWArGQWfYZ3mipQdaxQP05cqihZ9bPXTiwRKC pJ/OzLo3iU1GJnzEWHNBHRwl30nAkDZdEx3JWIGuUkKMoAlNMHMkGAgbLF5pFfT9edVNUv MgVe1aaBP5/XbOF4cgMYSxi2iq8eEAI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-660-wjrKsoReO4ibwa5joUp36A-1; Fri, 17 Jun 2022 10:29:21 -0400 X-MC-Unique: wjrKsoReO4ibwa5joUp36A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 124AB2932481; Fri, 17 Jun 2022 14:29:21 +0000 (UTC) Received: from [10.22.18.98] (unknown [10.22.18.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E8762026609; Fri, 17 Jun 2022 14:29:20 +0000 (UTC) Message-ID: Date: Fri, 17 Jun 2022 10:29:20 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: Lockups due to "locking/rwsem: Make handoff bit handling more consistent" Content-Language: en-US To: Mel Gorman Cc: Zhenhua Ma , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , LKML , Michal Hocko References: <20220617134325.GC30825@techsingularity.net> From: Waiman Long In-Reply-To: <20220617134325.GC30825@techsingularity.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/17/22 09:43, Mel Gorman wrote: > Hi Waiman, > > I've received reports of lockups happening in kernels including > commit d257cc8cb8d5 ("locking/rwsem: Make handoff bit handling more > consistent"). The exact symptoms vary but usually it's either a soft lockup > (older kernel with a backport), the task hanging and never exiting or the > machine becomes generally unresponsive and ssh is broken. The problem > started in 5.16 and reliably bisected to commit d257cc8cb8d5. Reverting > the patch in 5.16, 5.17 and 5.18 finish the test successfully but I didn't > test a revert on 5.19-rc2 because of other changes layered on top. > > The reproducer is simple -- start pairs of CPU hogs pinned to a CPU with > different SCHED_RR priorities that run for a few seconds. It does not > hit every time but usually happens within 10 attempts. On 5.16 at least, > the tasks failed to exit and kept retrying to exit using the following path > > [<0>] rwsem_down_write_slowpath+0x2ad/0x580 > [<0>] unlink_file_vma+0x2c/0x50 > [<0>] free_pgtables+0xbe/0x110 > [<0>] exit_mmap+0xc1/0x220 > [<0>] mmput+0x52/0x110 > [<0>] do_exit+0x2ec/0xb00 > [<0>] do_group_exit+0x2d/0x90 > [<0>] get_signal+0xb6/0x920 > [<0>] arch_do_signal_or_restart+0xba/0x700 > [<0>] exit_to_user_mode_prepare+0xb7/0x230 > [<0>] irqentry_exit_to_user_mode+0x5/0x20 > [<0>] asm_sysvec_apic_timer_interrupt+0x12/0x20 > [<0>] preempt_schedule_thunk+0x16/0x18 > [<0>] rwsem_down_write_slowpath+0x2ad/0x580 > [<0>] unlink_file_vma+0x2c/0x50 > [<0>] free_pgtables+0xbe/0x110 > [<0>] exit_mmap+0xc1/0x220 > [<0>] mmput+0x52/0x110 > [<0>] do_exit+0x2ec/0xb00 > [<0>] do_group_exit+0x2d/0x90 > [<0>] get_signal+0xb6/0x920 > [<0>] arch_do_signal_or_restart+0xba/0x700 > [<0>] exit_to_user_mode_prepare+0xb7/0x230 > [<0>] irqentry_exit_to_user_mode+0x5/0x20 > [<0>] asm_sysvec_apic_timer_interrupt+0x12/0x20 > > The C file and shell script to run it are attached. > Thanks for the reproducer and I will try to reproduce it locally. It is a known issue that I have receive similar report from an Oracle engineer. That is the reason I posted commit 1ee326196c66 ("locking/rwsem: Always try to wake waiters in out_nolock path") that was merged in v5.19. I believe it helps but it may not be able to eliminate all possible race conditions. To make rwsem behave more like before commit d257cc8cb8d5 ("locking/rwsem: Make handoff bit handling more consistent"), I posted a follow-up patch https://lore.kernel.org/lkml/20220427173124.1428050-1-longman@redhat.com/ But it hasn't gotten review yet. I will try your reproducer to see if these patches are able to address the lockup problem. Thanks, Longman commit d257cc8cb8d5 ("locking/rwsem: Make handoff bit handling more consistent").