Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1768297ybk; Thu, 21 May 2020 15:00:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtHSsy3Malb91/aS9wmIXDQmAkS19Wvp+NyTLU7uVZQi5aaswz0o9CYgsyG5kk4hzkkBFb X-Received: by 2002:a17:906:3048:: with SMTP id d8mr5359090ejd.97.1590098447854; Thu, 21 May 2020 15:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590098447; cv=none; d=google.com; s=arc-20160816; b=IH8yIo8eQJxieLNaKE7pMJNQv38uw9FeHiNygsiVnpKzo0f26W+nvxKIsyitBGmJRv 3gT7x8bDDmEJ+5PqTtDTQ/Km5Wa35fsUnNY7BJQj9YZ9xtabfFljI0FzZn0irXkrJxCp nQLsM81OfpWdcxckP/mhrR6RS9re24SJ1WRd4zfQ2n6ENbGN/IYIdVMdsMscugbwU8w9 cM7L27o/NEvfue4NYbi7Y3EZX+7EO/VIvhYSjyBfjHYg9VJOPjIQ4mDYtrJiG5YKiDQs ML1ELyYL69TLj89FtD9bt36koS065lquOeCsK3s0nxMxXfB/O5uXNbPMep1smUWFahI0 MBaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=5B1+HMIDvT7snVXiXmhhirfPbIUt2RcF6P9jK7VVgzk=; b=nUDIrDyuw8R/KcNNaalzMn2AgvR1kvqzeuXYkRpaZeiMH/ETYZaoOBzeKnYwxCFPzR l3sNOcwAGQCHAYPfc2NTS5uNUFlpNxLJtBvTGcfTYNNbbt6372SYuGyF5PfJVyYKxudO zjHSVjqKEmtmR00310O5l9kEXWqSRDu8nb/kLK3EvGo2Rbc59ThT2URei8oetRh9L8FK M/sXZEScZ0Sb6rQ1B8P6YgN5amZxUEDxvQURmt5732PfA8I7Dv+zxyp4s9s7FrxFvBuA gqKIN0/gxDyjT02XCiYqeQxCGdWMJwGDnUx543VkIfcECrV8x/KqfhADMI8ynB8FmNtb rgtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=tfzseeFR; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a7si3668804edb.445.2020.05.21.15.00.16; Thu, 21 May 2020 15:00:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=tfzseeFR; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730465AbgEUV7W (ORCPT + 99 others); Thu, 21 May 2020 17:59:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729918AbgEUV7V (ORCPT ); Thu, 21 May 2020 17:59:21 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B24AC08C5C2 for ; Thu, 21 May 2020 14:59:20 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id o19so6778003qtr.10 for ; Thu, 21 May 2020 14:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=5B1+HMIDvT7snVXiXmhhirfPbIUt2RcF6P9jK7VVgzk=; b=tfzseeFRapr6mzYIpyevbB2Jr0bnMxnhrggEPvTJwKT1cNJUmOyzhNEEPC7YfmFN10 Leq8bJtwR9By5lcHPu1Udo3g0bnQUdDLbiLyiUxWzyBaErEnqpb7zOsiDxNzuM2DY5m3 9i2yn71sn05AqTGZbUV3FNlQ7ZJDjxLEs00cKA6PCnWfel6WSALIg9RBtqLJgEXELCof VnDtHFb0fobUgITmj7IgRam7lmriUKw5hSI013/Y1R8qjEoh55ee/UDqIrEF3v9Q5HYU QhDt6u4wHbqDq6tuAnx5yRdXaCqWqT71EZvmB6MnGSWGJ8dz1OAmtQO3ti3WC/Sg3XO+ PZAw== 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; bh=5B1+HMIDvT7snVXiXmhhirfPbIUt2RcF6P9jK7VVgzk=; b=G8K98PTTVnx2HtKq+sVU+Ny5OnAQIxy61l3TB6R5nUMnTn2XsUK29HeycyPiPlFUVD PcMREpU/ON2zMEodR7eqJmDJqn5iAuJrXTCha/fyLQxmCMhxsDFX6ImR8oGNi6ISSwWl g3uL0LiWkg+49Z1jFjflEZJeelgPwZ0Y4rfPTfMyscvB5xGcZCTb4bMt2rVsAs7IIAPm B8Vx7UMDUlNcKYMwY64AxRqT9wlIPM8jSsOmtrj8kdtt0EVgXV+bNmIz5jHqV9friFvQ 8nwgfUU+17W9c8fBk6uEbutEsPNDRtrTcuOodjs/vMHbmnWTupausaXw4CBOrJl85S8l KVPg== X-Gm-Message-State: AOAM532/fw1fRsQf17To6o1GXPNqcitHaSbSSa/qRz1TcXr4y5KnDTS5 Vi7x/sE2wncRpbQYv4ZL2ILCDMJkz5w= X-Received: by 2002:aed:37e7:: with SMTP id j94mr12705571qtb.57.1590098359373; Thu, 21 May 2020 14:59:19 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:4708]) by smtp.gmail.com with ESMTPSA id m13sm6939518qtm.12.2020.05.21.14.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 14:59:18 -0700 (PDT) Date: Thu, 21 May 2020 17:58:55 -0400 From: Johannes Weiner To: Hugh Dickins Cc: Michal Hocko , Naresh Kamboju , Chris Down , Yafang Shao , Anders Roxell , "Linux F2FS DEV, Mailing List" , linux-ext4 , linux-block , Andrew Morton , open list , Linux-Next Mailing List , linux-mm , Arnd Bergmann , Andreas Dilger , Jaegeuk Kim , Theodore Ts'o , Chao Yu , Andrea Arcangeli , Matthew Wilcox , Chao Yu , lkft-triage@lists.linaro.org, Roman Gushchin , Cgroups Subject: Re: mm: mkfs.ext4 invoked oom-killer on i386 - pagecache_get_page Message-ID: <20200521215855.GB815153@cmpxchg.org> References: <20200520190906.GA558281@chrisdown.name> <20200521095515.GK6462@dhcp22.suse.cz> <20200521105801.GL6462@dhcp22.suse.cz> <20200521124444.GP6462@dhcp22.suse.cz> <20200521191746.GB815980@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, May 21, 2020 at 01:06:28PM -0700, Hugh Dickins wrote: > On Thu, 21 May 2020, Johannes Weiner wrote: > > do_memsw_account() used to be automatically false when the cgroup > > controller was disabled. Now that it's replaced by > > cgroup_memory_noswap, for which this isn't true, make the > > mem_cgroup_disabled() checks explicit in the swap control API. > > > > [hannes@cmpxchg.org: use mem_cgroup_disabled() in all API functions] > > Reported-by: Naresh Kamboju > > Debugged-by: Hugh Dickins > > Debugged-by: Michal Hocko > > Signed-off-by: Johannes Weiner > > --- > > mm/memcontrol.c | 47 +++++++++++++++++++++++++++++++++++++++++------ > > 1 file changed, 41 insertions(+), 6 deletions(-) > > I'm certainly not against a mem_cgroup_disabled() check in the only > place that's been observed to need it, as a fixup to merge into your > original patch; but this seems rather an over-reaction - and I'm a > little surprised that setting mem_cgroup_disabled() doesn't just > force cgroup_memory_noswap, saving repetitious checks elsewhere > (perhaps there's a difficulty in that, I haven't looked). Fair enough, I changed it to set the flag at initialization time if mem_cgroup_disabled(). I was never a fan of the old flags, where it was never clear what was commandline, and what was internal runtime state - do_swap_account? really_do_swap_account? But I think it's straight-forward in this case now. > Historically, I think we've added mem_cgroup_disabled() checks > (accessing a cacheline we'd rather avoid) where they're necessary, > rather than at every "interface". To me that always seemed like bugs waiting to happen. Like this one! It's a jump label nowadays, so I've been liberal with these to avoid subtle bugs. > And you seem to be in a very "goto out" mood today - we all have > our "goto out" days, alternating with our "return 0" days :) :-) But I agree, best to keep this fixup self-contained and defer anything else to separate cleanup patches. How about the below? It survives a swaptest with cgroup_disable=memory for me. Hugh, I started with your patch, which is why I kept you as the author, but as the patch now (and arguably the previous one) is sufficiently different, I dropped that now. I hope that's okay. --- From d9e7ed15d1c9248a3fd99e35e82437549154dac7 Mon Sep 17 00:00:00 2001 From: Johannes Weiner Date: Thu, 21 May 2020 17:44:25 -0400 Subject: [PATCH] mm: memcontrol: prepare swap controller setup for integration fix Fix crash with cgroup_disable=memory: > > > > + mkfs -t ext4 /dev/disk/by-id/ata-TOSHIBA_MG04ACA100N_Y8NRK0BPF6XF > > > > mke2fs 1.43.8 (1-Jan-2018) > > > > Creating filesystem with 244190646 4k blocks and 61054976 inodes > > > > Filesystem UUID: 3bb1a285-2cb4-44b4-b6e8-62548f3ac620 > > > > Superblock backups stored on blocks: > > > > 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, > > > > 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, > > > > 102400000, 214990848 > > > > Allocating group tables: 0/7453 done > > > > Writing inode tables: 0/7453 done > > > > Creating journal (262144 blocks): [ 35.502102] BUG: kernel NULL > > > > pointer dereference, address: 000000c8 > > > > [ 35.508372] #PF: supervisor read access in kernel mode > > > > [ 35.513506] #PF: error_code(0x0000) - not-present page > > > > [ 35.518638] *pde = 00000000 > > > > [ 35.521514] Oops: 0000 [#1] SMP > > > > [ 35.524652] CPU: 0 PID: 145 Comm: kswapd0 Not tainted > > > > 5.7.0-rc6-next-20200519+ #1 > > > > [ 35.532121] Hardware name: Supermicro SYS-5019S-ML/X11SSH-F, BIOS > > > > 2.2 05/23/2018 > > > > [ 35.539507] EIP: mem_cgroup_get_nr_swap_pages+0x28/0x60 Swap accounting used to be implied-disabled when the cgroup controller was disabled. Restore that for the new cgroup_memory_noswap, so that we bail out of this function instead of dereferencing a NULL memcg. Reported-by: Naresh Kamboju Debugged-by: Hugh Dickins Debugged-by: Michal Hocko Signed-off-by: Johannes Weiner --- mm/memcontrol.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3e000a316b59..e3b785d6e771 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -7075,7 +7075,11 @@ static struct cftype memsw_files[] = { static int __init mem_cgroup_swap_init(void) { - if (mem_cgroup_disabled() || cgroup_memory_noswap) + /* No memory control -> no swap control */ + if (mem_cgroup_disabled()) + cgroup_memory_noswap = true; + + if (cgroup_memory_noswap) return 0; WARN_ON(cgroup_add_dfl_cftypes(&memory_cgrp_subsys, swap_files)); -- 2.26.2