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 E16D1C49ED7 for ; Fri, 20 Sep 2019 14:31:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A7479206C2 for ; Fri, 20 Sep 2019 14:31:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VBwkT+GO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7479206C2 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 427B96B0005; Fri, 20 Sep 2019 10:31:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B0956B0007; Fri, 20 Sep 2019 10:31:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 250F36B0008; Fri, 20 Sep 2019 10:31:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id EFF166B0005 for ; Fri, 20 Sep 2019 10:31:29 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id A0699181AC9B6 for ; Fri, 20 Sep 2019 14:31:29 +0000 (UTC) X-FDA: 75955537098.10.space55_8165e726d472d X-HE-Tag: space55_8165e726d472d X-Filterd-Recvd-Size: 4329 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Sep 2019 14:31:29 +0000 (UTC) Received: by mail-lj1-f193.google.com with SMTP id q64so7253180ljb.12 for ; Fri, 20 Sep 2019 07:31:28 -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=/UmKmcVdfGL0BM9xGNj29OG99mu12S2rRbnsThHYS5s=; b=VBwkT+GOvE6WhewRzb8gEAcfycr3A0ewtfXEzwupM26LaUIU5UgbDTBdRydyd1uZLe alI4qn+V5JBIcLczrxIEmPo4F/tvBUhjDP/hsqh5P+nZj0lkruGMN8Fr230gWgXhuzIS C4tsv/YvLTFXH6IIm0F5QNcY5S1OPbOwaOjHoM6AfhlxFCaLM5BCMoyT7CglKgZjMdC5 xpUJ08c7BDB4Y4pejdwwZmrAK9HI7p1aFtu+oNXaCwocp5Th4bERX+teYDoXSiKIvhEy gc9wXY1egizDGxO1gfaL+VRaX8q01t02lyQvVMy+piZwkpurWiX6YY7VRcx40+A1ttcq TqdQ== 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=/UmKmcVdfGL0BM9xGNj29OG99mu12S2rRbnsThHYS5s=; b=fFyGOe7V3f/bCqZs5l6Oix5xkxu4upIlnxga2rdupJEZYfKkrgJQ6bORo19ccHVXMR hJupKiOX05GCZ7ICQ5TxPEKH3bcouaKi+HiieqKHGwsqcE7D/nrxZ7l82ueZeGy7HSPg zF8ljOUrX5Xeu2a6DvWrlkZw4WQohKZaKLbeJ6IThR9HazWA7DcYhbJhxIQ6xoVyXo6g HAFGls/XDIYBlUKkR+X7OqJhwU4o7/VHDvt2XNEfaF69Mhy7sOTvDiICZpJgklplpwhW XyCHfrTub4qzgzH7S3+F2d8o7/2d5W+8+AxF4OHGQWXJzwm7hl+YYnkvMDr+TC4P6vYw fCFg== X-Gm-Message-State: APjAAAVwHgm6zAicvJPOXhn722yF6d4PwoUWFQwj1Qx1RZnqiQJDWd3P 33RkxHnibNbxKU0pKcxAYiVhY3W21uY= X-Google-Smtp-Source: APXvYqyLzlsjpVbQcNQ6ef6GTDOk1e4X5tDUNzj8rguwYrEjgY6qCI+c0KT+yKYy2gDBoOlPkP0jHA== X-Received: by 2002:a2e:1409:: with SMTP id u9mr9522774ljd.162.1568989887598; Fri, 20 Sep 2019 07:31:27 -0700 (PDT) Received: from uranus.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id k28sm527415lfj.33.2019.09.20.07.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2019 07:31:26 -0700 (PDT) Received: by uranus.localdomain (Postfix, from userid 1000) id 8A2FE460473; Fri, 20 Sep 2019 17:31:23 +0300 (MSK) Date: Fri, 20 Sep 2019 17:31:23 +0300 From: Cyrill Gorcunov To: Kirill Tkhai Cc: LKML , Linux MM , Johannes Weiner , Michal Hocko , Vladimir Davydov Subject: Re: [PATCH] mm, memcg: assign shrinker_map before kvfree Message-ID: <20190920143123.GI2507@uranus.lan> References: <20190920122907.GG2507@uranus.lan> <8a4b5293-6f79-2a5d-4ac8-f8fc17f13b6e@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8a4b5293-6f79-2a5d-4ac8-f8fc17f13b6e@virtuozzo.com> 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 05:11:00PM +0300, Kirill Tkhai wrote: > > The current scheme is following. We allocate shrinker_map in css_online, > while normal freeing happens in css_free. The NULLifying of pointer is needed > in case of "abnormal freeing", when memcg_free_shrinker_maps() is called > from memcg_alloc_shrinker_maps(). The NULLifying guarantees, we won't free > pn->shrinker_map twice. > > There are no races or problems with kvfree() and rcu_assign_pointer() order, > because of nobody can reference shrinker_map before memcg is online. > > In case of this rcu_assign_pointer() confuses, we may just remove is from > the function, and call it only on css_free. Something like the below: Kirill, I know that there is no problem now (as I pointed in changelog), simply a regular pattern of free after assign is being reversed, which made me nervious. Anyway dropping assigns doesn't help much from my pov so lets leave it as is. The good point is that we've this conversation and if someone get a bit confused in future the google will reveal this text. Which is enough I think.