Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp256617ybt; Tue, 16 Jun 2020 23:32:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUAbdIi1NFke/eKbxQRIHteiHSBZrQjT7uQgDmtiM2hczc71WIiEs3qow0P8F3o1yftgdL X-Received: by 2002:a17:906:af4d:: with SMTP id ly13mr5893999ejb.250.1592375578532; Tue, 16 Jun 2020 23:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592375578; cv=none; d=google.com; s=arc-20160816; b=BUGuGc6N+W6Qt/drjALOF5vZHkKdbdHshK4n/uplVorJvMSVqgGmUDt0hDEILOxlCb 7l8U80eadGU+lPl5Rzh2aRtTRZ6cJ4z7VCDNZM+aF4OS7QWms21VVRZuWtqG5pDuL4sT ZWWw6kTTv8qEYPz+1gu8hRL4QAYUEsx/b9LgqTnncTyt3CLshyIFQ3o6u1M35jI5B9UQ DA+jwZNJPx2z7tQRygy+E7xvc/mBYC1ulVuoS2IuKA8B9g6pR2WJGcXLEyCUnVfWG5Je TwnguR6zWM/otHRycYbq4gYF4NSHygiXWqfyOAmNLPoDUP9S0z6XbeEeADwY5U2idLdu gnPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=xyNqLKkTkvhzaA5WIPNmUhrKUCZ/UNf8ZXPhmsM3X28=; b=vtn6zbNH2xhzD+mF99O+pq3Sy/oqucV3vXW3BqC59xuyh9bgkD2o9vZsi3v6PnDdxX Ckx+eNp1ibp9c5f4mdCO8OcL226GApYzP7J/eoI3bfgXfthPZA6Ajv4mKYuWd6bzp/Q6 PcA0a6gbMFu1+8NoGcoJ4bd4+sdVfo2B7PtmBUPLFSvhBTY3KiBLLSNUbID0zL47RJSJ bBSL0qXvhHXs1pFzKRABN9UWYn6mBCwtz+iOFiZbDVPwrCy2o5N6WkzTZr8CEHG9hyhB IYep0tll3CNPx85giMjfGKWKCP7LI9Js+nqpgnA/75TguoVCwUc5MsWxAlh1nerSS8sK d3sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jeG4FjV0; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lj21si12803304ejb.324.2020.06.16.23.32.35; Tue, 16 Jun 2020 23:32:58 -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=@google.com header.s=20161025 header.b=jeG4FjV0; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726881AbgFQGaL (ORCPT + 99 others); Wed, 17 Jun 2020 02:30:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726769AbgFQGaL (ORCPT ); Wed, 17 Jun 2020 02:30:11 -0400 Received: from mail-yb1-xb41.google.com (mail-yb1-xb41.google.com [IPv6:2607:f8b0:4864:20::b41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25386C061573 for ; Tue, 16 Jun 2020 23:30:11 -0700 (PDT) Received: by mail-yb1-xb41.google.com with SMTP id j202so715943ybg.6 for ; Tue, 16 Jun 2020 23:30:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xyNqLKkTkvhzaA5WIPNmUhrKUCZ/UNf8ZXPhmsM3X28=; b=jeG4FjV0hqv4kB0BcxsmpyNd4zjKL6ficNUfH93IC2J1884QNcosr9HycGBrsTPv/q LmSvrISeT8v6kC4YnEGAlsIZmgfxXlMMWN10yCoXrOe6ZHWndNq0GtrPoKIojS58AhQZ pxJgXPdE4QFzmV7iebWvHWUn9aZ9Bk/u8Zh4pFFNJaZN5oXsjH/1crWyAAyKzrZzkzKG z8micmgTnmFlVMl2AMmykSHgc+m2QzKEmbXOlh9jIEF4SgI9srlGewJ6IUgGK7yo8wbI GOt47oJjXfy23FPYiDT6T5KM0LWxai87OTjEkl3UD7r6ukE3gbkHGuRM2ijvG2lu/Z3p t4jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xyNqLKkTkvhzaA5WIPNmUhrKUCZ/UNf8ZXPhmsM3X28=; b=Ndb9vCrKA6EVUvWlhfaGCyiE1ZJShXSqjvZrAWvwPi6lxirjy8kIXPcbHcPaACbZaD JGHGYjxmrlyaeAC1ADZY0D31HTqDrjfvck+wJPu0JtacZOHK6xfPDDO7Yhj3xgxfJyCM 2CL1mj+Ntt+Lll1aJlMgEyDzUjbvDyifPrTLZV43BDl2BQs4ZWjIuaPPfwVq3LEFsJAW ywnCyOnaI7siGQiGlEuwXDqECdWtTdD/ky/jxmjU3KRQkxTRPIkxBTXXwYbaDLTCLItz r4V533MBaaxIiazXTIhPJru2gPrglF2rJb14Fl5Lz6mpAc+UkYPQWkJ7fuWBgybHHzvT JK5g== X-Gm-Message-State: AOAM532I9MrotwTQqQ6iHATnPp0EDEXKghuk3/Gedbo4bPqCTt7AI1NO sjgvU7VGg56cju3j2YJQUARFEltzC3XC3qE8SHgNSC7Hds4= X-Received: by 2002:a25:2f4f:: with SMTP id v76mr10953670ybv.7.1592375409854; Tue, 16 Jun 2020 23:30:09 -0700 (PDT) MIME-Version: 1.0 References: <20200616045108.GP75760@lianli.shorne-pla.net> <20200616191943.GA1401039@lianli.shorne-pla.net> <20200617053539.GB1401039@lianli.shorne-pla.net> <20200617060734.GC1401039@lianli.shorne-pla.net> In-Reply-To: <20200617060734.GC1401039@lianli.shorne-pla.net> From: Michel Lespinasse Date: Tue, 16 Jun 2020 23:29:56 -0700 Message-ID: Subject: Re: mm lock issue while booting Linux on 5.8-rc1 for RISC-V To: Stafford Horne Cc: Atish Patra , Palmer Dabbelt , linux-riscv , LKML , Bjorn Topel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 16, 2020 at 11:07 PM Stafford Horne wrote: > On Wed, Jun 17, 2020 at 02:35:39PM +0900, Stafford Horne wrote: > > On Tue, Jun 16, 2020 at 01:47:24PM -0700, Michel Lespinasse wrote: > > > This makes me wonder actually - maybe there is a latent bug that got > > > exposed after my change added the rwsem_is_locked assertion to the > > > lockdep_assert_held one. If that is the case, it may be helpful to > > > bisect when that issue first appeared, by testing before my patchset > > > with VM_BUG_ON(!rwsem_is_locked(&walk.mm->mmap_lock)) added to > > > walk_page_range() / walk_page_range_novma() / walk_page_vma() ... > > > > Hello, > > > > I tried to bisect it, but I think this issue goes much further back. > > > > Just with the below patch booting fails all the way back to v5.7. > > > > What does this mean by they way, why would mmap_assert_locked() want to assert > > that the rwsem_is_locked() is not true? It's the opposite - VM_BUG_ON(cond) triggers if cond is true, so in other words it asserts that cond is false. Yeah, I agree it is kinda confusing. But in our case, it asserts that the rwsem is locked, which is what we want. > The openrisc code that was walking the page ranges was not locking mm. I have > added the below patch to v5.8-rc1 and it seems to work fine. I will send a > better patch in a bit. > > iff --git a/arch/openrisc/kernel/dma.c b/arch/openrisc/kernel/dma.c > index c152a68811dd..bd5f05dd9174 100644 > --- a/arch/openrisc/kernel/dma.c > +++ b/arch/openrisc/kernel/dma.c > @@ -74,8 +74,10 @@ void *arch_dma_set_uncached(void *cpu_addr, size_t size) > * We need to iterate through the pages, clearing the dcache for > * them and setting the cache-inhibit bit. > */ > + mmap_read_lock(&init_mm); > error = walk_page_range(&init_mm, va, va + size, &set_nocache_walk_ops, > NULL); > + mmap_read_unlock(&init_mm); > if (error) > return ERR_PTR(error); > return cpu_addr; > @@ -85,9 +87,11 @@ void arch_dma_clear_uncached(void *cpu_addr, size_t size) > { > unsigned long va = (unsigned long)cpu_addr; > > + mmap_read_lock(&init_mm); > /* walk_page_range shouldn't be able to fail here */ > WARN_ON(walk_page_range(&init_mm, va, va + size, > &clear_nocache_walk_ops, NULL)); > + mmap_read_unlock(&init_mm); > } Thanks a lot for getting to the bottom of this. I think this is the proper fix.