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=-2.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 31504C4CECD for ; Fri, 20 Sep 2019 13:40:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C4D3D206B6 for ; Fri, 20 Sep 2019 13:40:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Lb/9WGxl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4D3D206B6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 389B56B0003; Fri, 20 Sep 2019 09:40:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 33A426B0005; Fri, 20 Sep 2019 09:40:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 22BE66B0006; Fri, 20 Sep 2019 09:40:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0117.hostedemail.com [216.40.44.117]) by kanga.kvack.org (Postfix) with ESMTP id F0D776B0003 for ; Fri, 20 Sep 2019 09:40:11 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 9CE8020BEA for ; Fri, 20 Sep 2019 13:40:11 +0000 (UTC) X-FDA: 75955407822.11.nerve90_76096c050031b X-HE-Tag: nerve90_76096c050031b X-Filterd-Recvd-Size: 4197 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Sep 2019 13:40:11 +0000 (UTC) Received: by mail-lj1-f193.google.com with SMTP id y23so7110495lje.9 for ; Fri, 20 Sep 2019 06:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/aF2m3SxvNf9OogoNs4YAr50tbC02AaJWORVsjothxQ=; b=Lb/9WGxlH0JyZSbH9fNIGJZn+7/vJ8eDxI/+hGw8mzuCrpGEVzs3JmR/chew3x0r6J RSVDsm4gzyXxEnn+oSnd5P3fGDT+l+//WAoSJoe1CNpZnGfcjtwbcIqLGMRvhmNoW3PQ YpAlcU5uvS1h6EI0vqHzLLCrBXIT7PT+teo/ewUXz/0ptHMpVtnJ0NUU2vFdg4J2SafD AHsEhF3pfvsKUBbPaHSvbIPs2RjUqK6VWPB5hxI1h9IUn/eYUYpdpw+bGr0sOxDU3QhY Gn1No8y/KR8K6Ptip+RuXHpfvOTmVRO32VIgu9bSEvqcJsIJS76JgMAJNXdjkXzyDkWO IVrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/aF2m3SxvNf9OogoNs4YAr50tbC02AaJWORVsjothxQ=; b=Zd48oup5wF5HTg+GZiEo/ZAvpb34TP58c4zXBqM2VOigOzFQvEXTQ9oiFgzeh6x9D7 biUHfxEHAkqKcDhfdzHbBGdQ1ZlMKG9/IjplrRmCQuG1p07urTqYw8P9VHeQjYQr7FUz qF6a3qR0E+IDOqG1tUNLs69wETrHJdfshbvIwsF1nv6nBY7iL7xHpRoUlukNvxmpqOCd 9XHyYBSTk2vPw8eXEPWgb4qS/urpF1AWX9j7XO6qGylqOvfy2/UGtz7BHsm8CAzN3U3/ oSIJkfzsz7iMmObVqVtIxbPVZOe/rBR+75PyYqxbax5I4rSOB4HrZVRJheMkCuHvMs/v xG9g== X-Gm-Message-State: APjAAAW+fkOxJiW3CGraqrCyBbwHpEqFuz6oSuxJrIO1mcu3QcF4XpLe ZqE59PCLbpWONqpL+KQUHME= X-Google-Smtp-Source: APXvYqxh0ksapdjSV61T6tQiw1XbUJqUqeacsI6+QX2vpoPU8wuLGI7dzdVkUigS1GP2TKO9lwqZIg== X-Received: by 2002:a2e:442:: with SMTP id 63mr9352432lje.66.1568986809445; Fri, 20 Sep 2019 06:40:09 -0700 (PDT) Received: from uranus.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id k13sm450582ljc.96.2019.09.20.06.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2019 06:40:08 -0700 (PDT) Received: by uranus.localdomain (Postfix, from userid 1000) id 9F8FC460473; Fri, 20 Sep 2019 16:40:06 +0300 (MSK) Date: Fri, 20 Sep 2019 16:40:06 +0300 From: Cyrill Gorcunov To: "Kirill A. Shutemov" Cc: LKML , Linux MM , Johannes Weiner , Michal Hocko , Vladimir Davydov , Kirill Tkhai Subject: Re: [PATCH] mm, memcg: assign shrinker_map before kvfree Message-ID: <20190920134006.GH2507@uranus.lan> References: <20190920122907.GG2507@uranus.lan> <20190920132114.ofzphp53vqqjb3fs@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190920132114.ofzphp53vqqjb3fs@box> User-Agent: Mutt/1.12.1 (2019-06-15) 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 Fri, Sep 20, 2019 at 04:21:14PM +0300, Kirill A. Shutemov wrote: > On Fri, Sep 20, 2019 at 03:29:07PM +0300, Cyrill Gorcunov wrote: > > Currently there is a small gap between fetching pointer, calling > > kvfree and assign its value to nil. In current callgraph it is > > not a problem (since memcg_free_shrinker_maps is running from > > memcg_alloc_shrinker_maps and mem_cgroup_css_free only) still > > this looks suspicious and we can easily eliminate the gap at all. > > With this logic it will still look suspicious since you don't wait > a grace period before freeing the map. Probably, but as far as I see we're using mutex here to order requests. I'm not sure, maybe ktkhai@ made the code to use free before the assign intentionally? As I said there is no bug it the code right now just forced me to stop and reread it several times due to this gap. If you look into other code places where we use similar technique we always assign before free.