From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD9AEC433E2 for ; Tue, 15 Sep 2020 15:42:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 554C3208E4 for ; Tue, 15 Sep 2020 15:42:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="v1qw0gBh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727327AbgIOPmR (ORCPT ); Tue, 15 Sep 2020 11:42:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727104AbgIOPGw (ORCPT ); Tue, 15 Sep 2020 11:06:52 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 377F7C061788; Tue, 15 Sep 2020 08:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=FlgVyuFGB64eIIcoPW84zIw7iDWXEV4cUSLn1lc3f0w=; b=v1qw0gBhOHIgF99ipVZK2g5laF bcoNJabkxU0K3HLLkB3b4uHFynM6wnDUyYDwbbOiySFM67wkAm4Ni6dBeZYfDyfVmpeWwA6DisXUp S1J8ExYnCMofyc6wuQ0w3zDerVwkUeuDCYfTVL5HDU3jIZ9sqZ35I1hghTrM5FRLnaNj557Ilo3N0 KPm3YkLPBD/v+G6oN+yn9pu1JRk0BZqcduJCSeQHcq7/cb3UJDkF84gJGIeMynjlGcjkV/n/DmM5m YsGqNjypFFXlJlKvgie8tNzz89uSbpm5Bqnjc0aY8mxs8mdWdv/S3P4WydWo9CH/K15Zu3+922hdp dCfCv5dg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kICX6-0008RR-0S; Tue, 15 Sep 2020 15:06:12 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 2F896301E02; Tue, 15 Sep 2020 17:06:11 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 07EA6299BA21D; Tue, 15 Sep 2020 17:06:11 +0200 (CEST) Date: Tue, 15 Sep 2020 17:06:10 +0200 From: peterz@infradead.org To: Hou Tao Cc: Ingo Molnar , Oleg Nesterov , Will Deacon , Dennis Zhou , Tejun Heo , "Christoph Lameter" , , Subject: Re: [RFC PATCH] locking/percpu-rwsem: use this_cpu_{inc|dec}() for read_count Message-ID: <20200915150610.GC2674@hirez.programming.kicks-ass.net> References: <20200915140750.137881-1-houtao1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200915140750.137881-1-houtao1@huawei.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 15, 2020 at 10:07:50PM +0800, Hou Tao wrote: > Under aarch64, __this_cpu_inc() is neither IRQ-safe nor atomic, so > when percpu_up_read() is invoked under IRQ-context (e.g. aio completion), > and it interrupts the process on the same CPU which is invoking > percpu_down_read(), the decreasement on read_count may lost and > the final value of read_count on the CPU will be unexpected > as shown below: > Fixing it by using the IRQ-safe helper this_cpu_inc|dec() for > operations on read_count. > > Another plausible fix is to state that percpu-rwsem can NOT be > used under IRQ context and convert all users which may > use it under IRQ context. *groan*... So yeah, fs/super totally abuses percpu_rwsem, and yes, using it from IRQ context is totally out of spec. That said, we've (grudgingly) accomodated them before. This seems to be a fairly long standing issue, and certainly not unique to ARM64 either (Power, and anyone else using asm-gemeric/percpu.h, should be similarly affected I think). The issue seems to stem from Oleg's original rewrite: a1fd3e24d8a4 ("percpu_rw_semaphore: reimplement to not block the readers unnecessarily") and is certainly an understandable mistake. I'm torn on what to do, using this_cpu over __this_cpu is going to adversely affect code-gen (and possibly performance) for all the percpu-rwsem users that are not quite so 'creative'.