From patchwork Mon Feb 28 12:21:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12763172 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE11FC433FE for ; Mon, 28 Feb 2022 12:24:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5744F8D000C; Mon, 28 Feb 2022 07:24:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FBE28D0001; Mon, 28 Feb 2022 07:24:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39CFC8D000C; Mon, 28 Feb 2022 07:24:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0209.hostedemail.com [216.40.44.209]) by kanga.kvack.org (Postfix) with ESMTP id 27F538D0001 for ; Mon, 28 Feb 2022 07:24:19 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E02C68249980 for ; Mon, 28 Feb 2022 12:24:18 +0000 (UTC) X-FDA: 79192106196.25.66F9D5D Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf09.hostedemail.com (Postfix) with ESMTP id 29BDC140008 for ; Mon, 28 Feb 2022 12:24:17 +0000 (UTC) Received: by mail-pl1-f177.google.com with SMTP id bd1so10535177plb.13 for ; Mon, 28 Feb 2022 04:24:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OoMgzdYapj8GOdfPEOkybEme/3XTyQ2VrTMps0q2PrA=; b=MY4WDJ8X56A+gQ/cLVJur3SrDm3EQKN4EZJt5lZ+9Cjo6Qf9bggHRbRFFzT61hhveJ 6llCa/oKNMcsL76YUQw6b2d6O43L82wgPEiEHoU+ucBYNIVlHE3DWygEJoZi6YSvWJ67 /wPNjrpz1ZMRw0ww9cakaygssVdi8m5NyOgvH0cttq0NVGVWMiO+8SW6Ce6TYCW9DpUz CCfNEsXaEm1bwlznl+crzJ8BZNp/0S/lJuMXy53yMDCRRI/6DVnvCVD+8L9n8BQ/0FsJ 0V/AkT/2mppxZSGo9WhzogNTJG6buGPwCZ8xc4qX9CCzzQd2534lOpSgMCU3uGRGYOUO NpaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OoMgzdYapj8GOdfPEOkybEme/3XTyQ2VrTMps0q2PrA=; b=pvV/Mrxsem1Q62q69KW2hY/XQwPlg1l6WE5aXMtwnZbo8F2YIRJ49Bm8IwCjMXTKQI GPOInyohwDM90aaE55t4pHz6UYqkb2L646/66AljZIhqKpq+nmnPh2taATrmHlq3Wn1K x/5jn9C4b9qq0m6vLPd1K7XjmXKfMin/0gzKmsaewVKHJ8SdIoknyR/AoluNSlugbRXj MAFxbo3HsPzql3iEQ6I55qeWpo6L2rPSbcarQxBMFh40BpVOsGjbB8w/RmOEl4dqlnc+ OGjsbtfEF4cXojmMbmd0WN/kaNtjlW7obj06Rf4yQjyIf6t5zOtzsjaLW76ECHhZrKTl aO3A== X-Gm-Message-State: AOAM532ZXRs9Vr7bzSB2ZlYo/T+JqHKVKCbz+SOVEO9sRuHJ78Hc7jHx Rr2WD+uzQmg6tHx9mWUCz5pJlg== X-Google-Smtp-Source: ABdhPJxledOS9MW9Pak+bHPtviUjpNtJQSZYmAT5JHc/iQf/jt1NmPdvAPkhddFMB/KNePUGkwRzZQ== X-Received: by 2002:a17:90a:d511:b0:1bc:50c9:8d8a with SMTP id t17-20020a17090ad51100b001bc50c98d8amr16432585pju.112.1646051057271; Mon, 28 Feb 2022 04:24:17 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.227]) by smtp.gmail.com with ESMTPSA id ep22-20020a17090ae65600b001b92477db10sm10466753pjb.29.2022.02.28.04.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 04:24:17 -0800 (PST) From: Muchun Song To: willy@infradead.org, akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, shakeelb@google.com, roman.gushchin@linux.dev, shy828301@gmail.com, alexs@kernel.org, richard.weiyang@gmail.com, david@fromorbit.com, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, jaegeuk@kernel.org, chao@kernel.org, kari.argillander@gmail.com, vbabka@suse.cz Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, zhengqi.arch@bytedance.com, duanxiongchun@bytedance.com, fam.zheng@bytedance.com, smuchun@gmail.com, Muchun Song Subject: [PATCH v6 14/16] mm: memcontrol: fix cannot alloc the maximum memcg ID Date: Mon, 28 Feb 2022 20:21:24 +0800 Message-Id: <20220228122126.37293-15-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220228122126.37293-1-songmuchun@bytedance.com> References: <20220228122126.37293-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 29BDC140008 X-Stat-Signature: qqud7ojcskyqzs9tg8yyuyiyz5xw361w Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=MY4WDJ8X; spf=pass (imf09.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1646051057-502655 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: The idr_alloc() does not include @max ID. So in the current implementation, the maximum memcg ID is 65534 instead of 65535. It seems a bug. So fix this. Signed-off-by: Muchun Song --- mm/memcontrol.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 809dfa4b2abc..cbe6f9bb37bb 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5029,8 +5029,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void) return ERR_PTR(error); memcg->id.id = idr_alloc(&mem_cgroup_idr, NULL, - 1, MEM_CGROUP_ID_MAX, - GFP_KERNEL); + 1, MEM_CGROUP_ID_MAX + 1, GFP_KERNEL); if (memcg->id.id < 0) { error = memcg->id.id; goto fail;