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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 64D56C388F9 for ; Tue, 27 Oct 2020 07:34:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BB9832071A for ; Tue, 27 Oct 2020 07:34:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oss-volkswagen-com.20150623.gappssmtp.com header.i=@oss-volkswagen-com.20150623.gappssmtp.com header.b="RZfyB5Pz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB9832071A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=oss.volkswagen.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 259656B006E; Tue, 27 Oct 2020 03:34:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 207936B0070; Tue, 27 Oct 2020 03:34:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F6036B0071; Tue, 27 Oct 2020 03:34:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0191.hostedemail.com [216.40.44.191]) by kanga.kvack.org (Postfix) with ESMTP id CC5916B006E for ; Tue, 27 Oct 2020 03:34:28 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6C6E91EE6 for ; Tue, 27 Oct 2020 07:34:28 +0000 (UTC) X-FDA: 77416892616.25.touch77_6302b4b2727a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 4640F1804E3A1 for ; Tue, 27 Oct 2020 07:34:28 +0000 (UTC) X-HE-Tag: touch77_6302b4b2727a X-Filterd-Recvd-Size: 4866 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 27 Oct 2020 07:34:27 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id m20so615239ljj.5 for ; Tue, 27 Oct 2020 00:34:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss-volkswagen-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GnEYGtyyl1hDuFTflbyIGL1IYqLyluHORuYTnOY+FcQ=; b=RZfyB5PzeDzbElpJC+j1uHWYam0n2qqJakNaj6evWc6slhSxAjpQtB/hQzvLMrZ9O7 av64VA02gzeGB/dFrRBZfzkvnAGwUTIheeT43csd67qVFpMC36sBBtc0M79hwIC7wrjh n1lpGh7epfVW2i/Ow4ogx16Nx2r5dYJ1y54C4SuwuM5a4tRQ4MUCBUYJzLLyaErXqH9q oJW2A0A00JtbAPZGditSlVJ8HEcfGJ/9vnqh0Wiy+EPpupRZ+p8xpLt7Ohuyj0k+M+B2 R3C405ccACuajzOa0DHW3SJBY140Li+QKmuH51cC6Pm8pyL11/LbMRfu6ZHRfubtPtVg v2cg== 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=GnEYGtyyl1hDuFTflbyIGL1IYqLyluHORuYTnOY+FcQ=; b=sRgB8HvO5+mXCxOdMgLEDROj5B7a92ccqT9ltvQKBUtIOyrzXyj9uCDaP+XWZyEf/o CGER0BkcDWoSGU5JmfCiJJMK4h52D5VsOjHbdCzHx3Ob2wvRNMDLHnjk2MOt+5mcnxn2 fWOCReTGskgw79+1dBwwJzovzZsksFULHP7hLhMQG5xVNyCxUl7yGwDtcqwKJep5MfHV 05+cam+tF85xPnMIYD0GClAzXBquqQq/qGVOfgYsBigd/7bBR1rlM0M8IPf+hkZNzzgW vhxwFIRJMliAXMeD/1g+MPiLPtZvlPyKcSg33RKCWz+qWbvd65xv11fJZdbp4Rb1133D DvFA== X-Gm-Message-State: AOAM533KXRNV/s+18qSdBytQwWQhR8T0igY94D6XuXSnBHDsOgnePwY4 dBlcEUW1MRX05Oxr7L4oRLSlrTQtNJWr/S3XdP181g== X-Google-Smtp-Source: ABdhPJwUf2LOwos8TG1Q0HzP1/sZk6kId6m5bnQXUbYTy4h4ggRo+ulNtBaQEjwOOQsxZ3CQqimIpI7NwpA99yDrGAE= X-Received: by 2002:a05:651c:1b6:: with SMTP id c22mr522825ljn.447.1603784065891; Tue, 27 Oct 2020 00:34:25 -0700 (PDT) MIME-Version: 1.0 References: <20201023074759.46605-1-laurent@oss.volkswagen.com> <20201023110204.GA3925@linux> <20201023121129.GB3925@linux> In-Reply-To: From: Laurent Cremmer Date: Tue, 27 Oct 2020 08:34:14 +0100 Message-ID: Subject: Re: [PATCH] hugetlb: fix locking in region_add,region_cgh,allocate_file_region_entries To: Mike Kravetz Cc: Oscar Salvador , Andrew Morton , Mina Almasry , David Rientjes , linux-mm@kvack.org, Shuah Khan Content-Type: text/plain; charset="UTF-8" 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 10/23/20 5:11 AM, Oscar Salvador wrote: > > On Fri, Oct 23, 2020 at 01:32:54PM +0200, Laurent Cremmer wrote: > >> I came to the same conclusion with the help of David's remarks :-) . > >> And in the end, this patch would be more about fixing the readability > >> of the code than fixing a live problem per-se. If it ain't broken, > >> don't fix it as they say :-) > > > > Yeah, definitely the code could benefit from a cleanup, so no one > > has to stare at it for a while before he gets the idea. > > INDEED, those *region* routines dealing with reservation maps are difficult > to understand, and could benefit from some cleanup. Recent changes to add > support for reservation cgroup support made them even more complex. > > Laurent, thank you for taking the time to look into this. And thanks to > Oscar and David for their analysis. The suggested patch would make the > code more readable. However, that would be at the expense of another > (and unnecessary) lock/unlock cycle. I'll add cleanup of these routines > to my 'todo' list, but would be happy to work with anyone else who wants > to take on this task. > -- Hi Mike, I gave it a deeper look (although I'm not familiar enough with the whole subsystem to really qualify!) and could not come up with an easy "way" out. In the end it might depend on how often the error path is taken and if the unnecessary lock/unlock cycle does really hurt under pressure. What really tripped me (and smatch) is the erroneous " __must_hold(&resv->lock)" annotation of the allocate_file_region_entries function. It would be better suited to the function above (add_reservation_in_range). If you think that adding documentation would be helpful, I can do that. In any case, thanks for taking the time to review and consider adding to your todo list. much appreciated. Laurent.