Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2175096ybg; Thu, 30 Jul 2020 12:16:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3kHoq2yeBCEDSD4/CCe8p4Z5/TaqkILepCN6GqXHZsgdXVgmZGZ4f6YPHed2FDKzEGTtt X-Received: by 2002:aa7:d516:: with SMTP id y22mr471122edq.221.1596136607664; Thu, 30 Jul 2020 12:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596136607; cv=none; d=google.com; s=arc-20160816; b=kxiazH6y2wAUIdCrmvzOsIPqau2MAk2EIYkAbBcTTDKeyONlHVnCKcWiEsTYlSvlkR UbDdZ3rmqystDPPKOR9uI3nql9B3LaE2ucQS8PNfmx3LA8nHHlSN7w+Xq/2JbQD0hHxX joWV3HjH4cV4V5OtLY32MJEj58Yka2Tb10963bhjYPNQ3j+R3eRAnv3GkvFufPwgJber Wga3UBqvqOgkmi6WBXkJZYLfmG86o1xFVvx2ZyN3/4GMl4FYFSouOSLX8UjH/b9ew5Mx kCgcCJN2KBsvm99T1PHFh4hX86ocxSUPTuGmHklsZWWNcN1ODaFKB6SGQ2qviCKOU2ii Rp6A== 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=A4NiYN/fL3K8jec2SXRSUpaYIgmwzb4CRMYaIZHw2Wc=; b=odxruRv85DABuFB3tQ8oVRVBiTiMlhZEdGmXHrhuzCmISIBK+USUx1dxmDaPlENxe8 fgnLZLTZCnrbslApx6KBbMXJhTzBj+rzmVOFJMwOxrodMT7oljjodz1jFaqVqrEMBoYH UvPXYHlAqgYIR3GqqN3Ua1mA6EMMG2Iz5D8CSfxOp6fhpAGT/mj/+Mf9XNGLWWC9E0V6 zi8sVtP2JcHNhtJljEZQrJo7l/dTXyEQVWQSgqj3D+qrFPCBYl8Vog8lbt2NMkMbNnOq l8narcA9IHcPdbM6AY7pzB3u/M/BLCJVATol1DAJZXyOORTU0Oojqj5WUck4uyHMW/1Y 101A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Mo+shIuY; 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 a9si3650877ejf.124.2020.07.30.12.16.25; Thu, 30 Jul 2020 12:16: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=@google.com header.s=20161025 header.b=Mo+shIuY; 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 S1730417AbgG3TP6 (ORCPT + 99 others); Thu, 30 Jul 2020 15:15:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728276AbgG3TP5 (ORCPT ); Thu, 30 Jul 2020 15:15:57 -0400 Received: from mail-vk1-xa42.google.com (mail-vk1-xa42.google.com [IPv6:2607:f8b0:4864:20::a42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FDDAC061574 for ; Thu, 30 Jul 2020 12:15:56 -0700 (PDT) Received: by mail-vk1-xa42.google.com with SMTP id j7so351949vkk.12 for ; Thu, 30 Jul 2020 12:15:56 -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=A4NiYN/fL3K8jec2SXRSUpaYIgmwzb4CRMYaIZHw2Wc=; b=Mo+shIuYgxTD570H7jADBYlG25BTBtzrCa/DMP1/ZnB6du6o7y6Iu5HbWzAN4ikxdt uh0vY0TUwlLo/4mK3aDD1e2p9cYTU8AyeBViPTFM257sEPZ1poyvbt5TYlepaj0qNtEt T6A5+SmbejL5NQla83ikEicCbOq8JCHEIK5sTYxlIwibfj4+c4mw1IuGemr3C8pipv3c CUieCxgTJtNauBFRebXeOJmUf8NY2ibViaw3h42+IoleuNICpPq1BwhTUxp773yqsknX 53x9EuiMUs4Xa7aTN7i0TnOJM4c476XqN/ron4MOlLkMmKydzur14NSGoQeUJekKCsc+ NoRQ== 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=A4NiYN/fL3K8jec2SXRSUpaYIgmwzb4CRMYaIZHw2Wc=; b=OtI1vQyCOeinvR+qJ8sKWWX21mBs10sTe0nsTWrcAy0008edJjFaonHCoGhkEI9TZU 5hY6QgB6mq95lZHtEtJL2vjCB4rOaYe6XrcuQjD00vglyd9R66zMn0RY/7NUdt7kdkGx RlOIJhdtB75yNn7BWf1gzOWb4up3MajcuHGT06AZJ3HXScmOQduU53dzvh+JpOV6g0HY 27UjC++mrfEZC/uipn/gDzOK6GPC3lMlhkytUrnrM2YqBrzH/2vmnURMbiWeouYhDOik Hc0Aqc3IvSQtpPeT+1eCcKUXQkv1jt27tA7gf7EJAqzLSyxsHue+9iMUW6Ix1WWMdKIb ASuA== X-Gm-Message-State: AOAM531T1pqKZlZ+/mBzwk9FX7A08969yZw2z6UW10rroBufEcYckqlk 8DC4ZNFBtSJQPPa6o6jtQTnExG8NR+y2gMBV6od0ng== X-Received: by 2002:a1f:96c7:: with SMTP id y190mr310774vkd.5.1596136555382; Thu, 30 Jul 2020 12:15:55 -0700 (PDT) MIME-Version: 1.0 References: <20200716024527.4009170-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 30 Jul 2020 12:15:44 -0700 Message-ID: Subject: Re: [PATCH 1/1] staging: android: ashmem: Fix lockdep warning for write operation To: Joel Fernandes Cc: Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Todd Kjos , Martijn Coenen , Christian Brauner , Hridya Valsaraju , Michal Hocko , Hillf Danton , Eric Biggers , "open list:ANDROID DRIVERS" , linux-mm , LKML , kernel-team 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 Wed, Jul 29, 2020 at 8:24 PM Joel Fernandes wrote: > > On Wed, Jul 15, 2020 at 10:45 PM Suren Baghdasaryan wrote: > > > > syzbot report [1] describes a deadlock when write operation against an > > ashmem fd executed at the time when ashmem is shrinking its cache results > > in the following lock sequence: > > > > Possible unsafe locking scenario: > > > > CPU0 CPU1 > > ---- ---- > > lock(fs_reclaim); > > lock(&sb->s_type->i_mutex_key#13); > > lock(fs_reclaim); > > lock(&sb->s_type->i_mutex_key#13); > > > > kswapd takes fs_reclaim and then inode_lock while generic_perform_write > > takes inode_lock and then fs_reclaim. However ashmem does not support > > writing into backing shmem with a write syscall. The only way to change > > its content is to mmap it and operate on mapped memory. Therefore the race > > that lockdep is warning about is not valid. Resolve this by introducing a > > separate lockdep class for the backing shmem inodes. > > > > [1]: https://lkml.kernel.org/lkml/0000000000000b5f9d059aa2037f@google.com/ > > > > Signed-off-by: Suren Baghdasaryan > > --- > > Once Eric's nits are resolved: > > Reviewed-by: Joel Fernandes (Google) Thanks Joel! I'm fixing the nits and will report the patch shortly. One note about adding the "Fixes: " tag - this is a fix for a false positive lockdep warning and it's unclear which patch should be quoted here (I could not find a clear cause that started this warning). In similar situations, for example here: https://lkml.org/lkml/2020/6/15/958 developers seem to skip that tag. So I'll do the same. > > Thanks.