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=-14.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL 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 B5FE8C433DF for ; Thu, 30 Jul 2020 19:15:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 547B02074B for ; Thu, 30 Jul 2020 19:15:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Mo+shIuY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 547B02074B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 892D46B000C; Thu, 30 Jul 2020 15:15:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 844726B000D; Thu, 30 Jul 2020 15:15:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 732CE6B000E; Thu, 30 Jul 2020 15:15:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0093.hostedemail.com [216.40.44.93]) by kanga.kvack.org (Postfix) with ESMTP id 5F9B36B000C for ; Thu, 30 Jul 2020 15:15:57 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 2498D180AD807 for ; Thu, 30 Jul 2020 19:15:57 +0000 (UTC) X-FDA: 77095697154.09.touch86_5e13e9b26f7d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id E5156180AD80F for ; Thu, 30 Jul 2020 19:15:56 +0000 (UTC) X-HE-Tag: touch86_5e13e9b26f7d X-Filterd-Recvd-Size: 4989 Received: from mail-vk1-f195.google.com (mail-vk1-f195.google.com [209.85.221.195]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Thu, 30 Jul 2020 19:15:56 +0000 (UTC) Received: by mail-vk1-f195.google.com with SMTP id r197so1921448vkf.13 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=It90Ot97MUmjQHQOaprxDxLQBpvNJlJ7wXWqT4a2K9TtELBTxW/sXpcDJ4yvlZHlcm DXKhkOAEFyDV+AcEV0zCFlqRdfwtj/tEVcy8NSrj3qSg3Uc3pj153CZoquVapRuBuSlt PYoLz/VuJ+Ian2kdRfs7i9ADAEhLzsdNSonAW04XN+2nE26fApU1KrrYhlVWFU5KETBB zQznZB3xVAIy7rZm/0nOjf7OLrERDR8VYlyCU9XgRbJLbz4fmAsivT0icrmqsU8He0wR l84wIdyIgC+56OgAjQQi8WKhlhmOYYZJ4lOu7v8ghw261JwQ1p8Ig9tyAOzemLrKIisz yUZg== X-Gm-Message-State: AOAM533RBIaERXf1jR29L+6wtHYK9sCDH26zbbxzfPnVODBQqYCc5vcl nEAzjf+smQiSVP05sUWsajg1Y42OvcV0cT92zWPhAQ== X-Google-Smtp-Source: ABdhPJygcFQl2Dx9t0fnHvdutxsbUiu3tCDlK/opODfvCZT9YJsnyIQJdPdlNHeffyQM0HQhM6iIbwxUr1yjzgBWlLA= 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" X-Rspamd-Queue-Id: E5156180AD80F X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.