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=-0.6 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, URIBL_BLOCKED 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 5C9A7C2BA19 for ; Mon, 6 Apr 2020 14:29:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1C0F423EF6 for ; Mon, 6 Apr 2020 14:29:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OMZzJpgF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C0F423EF6 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 D77F58E0030; Mon, 6 Apr 2020 10:29:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D29438E000D; Mon, 6 Apr 2020 10:29:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C17328E0030; Mon, 6 Apr 2020 10:29:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id A5B128E000D for ; Mon, 6 Apr 2020 10:29:10 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 6D6F68248047 for ; Mon, 6 Apr 2020 14:29:10 +0000 (UTC) X-FDA: 76677662460.17.ice29_32f421a38a727 X-HE-Tag: ice29_32f421a38a727 X-Filterd-Recvd-Size: 4717 Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Mon, 6 Apr 2020 14:29:10 +0000 (UTC) Received: by mail-io1-f68.google.com with SMTP id h6so6107317iok.11 for ; Mon, 06 Apr 2020 07:29:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7WM4S351f4ID5K2ptibFrUq8sV6QHGPowgVK20mjpHE=; b=OMZzJpgF/DrkKj4MYx0Ud80zCxvY5nJKc6J7VRMbInUskQy9raGRkXT8h4zkluTDCX TQhtM+RRf/u5n/Hw8wFCLV1orjSPZepB/7J120f0CYnpVO1YIgPkvxQj/38diGSeWQ2a Bw3KMzBrgUJsToMJNYeM3yzqYWArSeuZ1Pad/2InJQ34QSDtaLIv3xnOacRnzBm3BlR4 svHJyHJCaeGMVooY5djpDxqbexSa9QyoaF7RGBZ/X+8kEaBFyllayTV8M1MxwfrfSTpp +mPa/B0H+pbJSfNQx2FusHW6j6joj1+0ER4jh6ayT1hmkbGvm0jXv/wZdij/NTdTua6n azRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7WM4S351f4ID5K2ptibFrUq8sV6QHGPowgVK20mjpHE=; b=FKhJUdz9pgJUJMlirC0kp6brFC1FWYRu+80y/h6Tf70CCCmzJJUVeH8bDat0J3+X/1 PNXJ4hDgksuvqqp4ddlnLQfUyK6rO97azin4U0A9rQ2n/E7jhaxt5QH5MQD5mcTMQzpe Ceo6/TL/yIduxZrB4KxARqqkdhxCIwsczznPbFfXds++yj9rfZbFQRbe0gxMtpGR3Rb0 Ujg/L/u3Q2g9zf6QW18h4hgJ8/QAgf+I7Sg93DykSLlbYTReinWt3gGlnmBOwwy2VX6n 32OknJAj9oX1XKEY2SmG6nhBiMIexU2YgAs2pnx80J9zThEPPdbJusfdWt0bBhn7J0l8 dPww== X-Gm-Message-State: AGi0PuZXEiBQ6zDnLheCe3hhCcWtays4/zeJOQ0P5gkM1/NpAplD6pz9 42ADjyCkqVMu0SOzvrVAfPTDHw8MELD8oB+WIjM= X-Google-Smtp-Source: APiQypIaZhPz4q3hgGM2LzlFAYX5veXgAHdmBn0u/RHqxfGXAQaX8WKh5fVn/QIt2RNaWh6TsbP6D7UHCiFi57GlB80= X-Received: by 2002:a05:6638:301:: with SMTP id w1mr19963180jap.109.1586183349567; Mon, 06 Apr 2020 07:29:09 -0700 (PDT) MIME-Version: 1.0 References: <1586177647-11889-1-git-send-email-laoar.shao@gmail.com> <20200406130533.GZ21484@bombadil.infradead.org> <20200406141153.GB21484@bombadil.infradead.org> <20200406142530.GC21484@bombadil.infradead.org> In-Reply-To: <20200406142530.GC21484@bombadil.infradead.org> From: Yafang Shao Date: Mon, 6 Apr 2020 22:28:33 +0800 Message-ID: Subject: Re: [PATCH] mm, memcg: fix error return value of mem_cgroup_alloc() To: Matthew Wilcox Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Linux MM Content-Type: text/plain; charset="UTF-8" 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 Mon, Apr 6, 2020 at 10:25 PM Matthew Wilcox wrote: > > On Mon, Apr 06, 2020 at 10:16:56PM +0800, Yafang Shao wrote: > > On Mon, Apr 6, 2020 at 10:11 PM Matthew Wilcox wrote: > > > > > > On Mon, Apr 06, 2020 at 10:09:55PM +0800, Yafang Shao wrote: > > > > What about ida_alloc_range() ? Should we correct it as well ? > > > > > > > > > > > > * Return: The allocated ID, or %-ENOMEM if memory could not be allocated, > > > > * or %-ENOSPC if there are no free IDs. > > > > */ > > > > int ida_alloc_range(struct ida *ida, unsigned int min, unsigned int max, > > > > gfp_t gfp) > > > > > > > > If there're no free IDs, ida_alloc_range() also returns ENOSPC. > > > > > > Do you want to check all the callers of ida_.*alloc()? > > > > Sorry, I can't your point. > > Changing the value returned by ida_alloc_range() would require checking > every caller to see if it would break anything. That's why I didn't > change it when I rewrote it. > Got it. Thanks for the explaination. > > I just find the mem_cgroup_css_alloc() will use ida too. > > mem_cgroup_css_alloc > > memcg_online_kmem > > memcg_alloc_cache_id > > ida_simple_get > > > > I think we should keep the behavior consistent here. > > ENOSPC doesn't make much sense here. So I'd do: > > id = ida_simple_get(&memcg_cache_ida, > 0, MEMCG_CACHES_MAX_SIZE, GFP_KERNEL); > + if (id == -ENOSPC) > + return -EBUSY; > if (id < 0) > return id; > Understood! Thanks Yafang