Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1586497ybj; Fri, 20 Sep 2019 12:56:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgPTTN+jiDd8mtm8LVUS7BwD3Gcf1Huu/PNwIwJ7wd1HAuyX2ZSfitkSR70Ss3o+8zqX4x X-Received: by 2002:a50:ab84:: with SMTP id u4mr23858471edc.13.1569009391001; Fri, 20 Sep 2019 12:56:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569009390; cv=none; d=google.com; s=arc-20160816; b=lVS9ROhn8xdW9hw9ArsMdN203xTqldUreiyCT5jQRLUBY5X0BlncingPGTOKHikafl H7lixEfE6e51uHUbAjjot5bxjWNzX0Tbw/WyscZc2Ats8VS+gbrkSbDwGwe9dy/aq+yl toZnXLt08FC4rwd8CNPVKdc9WCRUyvG+hS325qG9WtukpJA+GSdcnvO7rIYXZlL8Gm9L juARWQ7HU8jfrr5EmNckbkOHnlrLKCO5IGvL01cuUCJ9lTcga6UivUDzYXDHi/4DFMzY hJGfE351yZCSPtekBuBPaYhzELF2LDnfNuEhVW0+So+rmDWrJMgJ6AWmJ7sCKzBEGgNE szlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/aF2m3SxvNf9OogoNs4YAr50tbC02AaJWORVsjothxQ=; b=vUdnxnx5uc6eIzxP7txyvwaTwpfbgMy2TExqZQua7k0RA9/K87I3c28oSDF7QxxxBH gge+ZUuHQnkcH8DKfdAH7D8z9xQJFYMlRNz8AJT/EXZfJCvyTJV0fiFufGwai+X97B5b ivPjCK+eKttJyvpxzo9IOZ7bCjwhV0P4OA/b2h9y3jf1PcSwnsbi4AxLaIlk31nspuT3 u1a7Vj/AUqe20x6JK1K95+dj0vNtaYZml0O/SNqik5OQWyiBaOXWM7iH91pq3CV6z66K +oPEzqUE7VjHcli87LIIOH9QCgRPXk7AzJhO38ggSHvp1F7EE8aGIZ0umJHHrQfapGTm W/gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Lb/9WGxl"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2si1972544edq.264.2019.09.20.12.56.08; Fri, 20 Sep 2019 12:56:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Lb/9WGxl"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728084AbfITNkL (ORCPT + 99 others); Fri, 20 Sep 2019 09:40:11 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45052 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727736AbfITNkL (ORCPT ); Fri, 20 Sep 2019 09:40:11 -0400 Received: by mail-lj1-f194.google.com with SMTP id m13so7072795ljj.11 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=pBnhrcb07znrKoHoK3hSAjCG1ncDsjxwJxhiO81bJJSkU8g/MqTHhyHzj1T5MgBwga mPAUgk11dm/cZ7/4XNlv3MtZKnHQ3jwu0IsrdVT7QF9qskJl1oPApCZuAtxEvm0k3RxA rWfzmRbw/ELcsRV8BHQ5/XuaVZLHjnGKIGXJr0cKSpeAcfqN5bUqpPoZehbGVooo+TQd diD2UQNm5h4EYk2/htl8dVaehGs9Liw2QvoQu8QvLj5rgsEv5c1D6by7kOi61HYREUMe LGVF8hGN3ttFbycGtVO+4HjuRyG6wSEXI/TOKFjnc3cEnU45reqvCpe7Q769TZZIoSqS HXcw== X-Gm-Message-State: APjAAAUwu8NkQGN5G0XVFNruVTYEf7UCPO5jk/E/7aIBwqOOrdFJAhw9 nfiRB6lh25awfsyzpd6ZKeI= 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.