Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp593525ybz; Fri, 17 Apr 2020 06:45:07 -0700 (PDT) X-Google-Smtp-Source: APiQypLNyfAXa1ov8IkI+XztTkSBR3xgAAdSB0175JXobSTDfiC/Higdcb5pujWb+f6nQxz/1jdW X-Received: by 2002:a05:6402:4:: with SMTP id d4mr3022741edu.344.1587131107199; Fri, 17 Apr 2020 06:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587131107; cv=none; d=google.com; s=arc-20160816; b=q6b//UNttL2EAdtnMWrGcq0f71jWg90CEat5JeQ6+xsfb8gdOA9drww9/AR2a46097 vCOHDI7LXxXmegvyOBX4TXd3C+gruQogCtW7Gb8t5aFIJJn6hRCDEEAMB3kv9cItCbRJ YgOmHhlIAfj5GGMreCQjkU8mkg/jctfWIYQG811E9VbftaLryK71x2TsOK+leU4LArXp rIU5MwHgL+5yt4Bpb8aReRhxmXioYNmndaJzxMUEh3iG5NG0NzYUOI57WbsIdSsNqhsb Jy9BcGY02QguDVpzi0RF5E/cNpwShNTPf98UZmSitNjrYPkLYjmF4YlfPwPeGUjK6iBn ckmg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=tOZKi29bbKZWeRD8Sxlu38LfstaUnzJU2Zc3Cur0xnM=; b=uE8VPQfop+Wggi/XXsupqTnVX5jxMBGc1ewQczgRI4VkOv1rROIQ/dFMxYcvIFiDKA RJ3KnY+mFtQPg0asyrMwq+cMZzQFjaausYHnpMl4Jt7hkjkRZkoSGc+u2I/2oZKxLwBs 4LI7MhOef6Ee34zZrYZOHLVX4NGZjKkKxZkGsqpzsGUbSL51U5BYLWJN/bLJ8IKQpu+z p1hAwmzj09jGnxRNGYA1IP81GfdWVksjI4dh56Jw94GXnwgQmJ0jl1/ycLqXix1yAi3Y JNRFm9Jv4F8FvWMO1nwerEJgNA2zWqElMRIWZEJBo7+8WffG3I1aEppV6rJqVS3zF3qx Mtyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u9si13733117edj.180.2020.04.17.06.44.43; Fri, 17 Apr 2020 06:45:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730718AbgDQNmw (ORCPT + 99 others); Fri, 17 Apr 2020 09:42:52 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:52164 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730597AbgDQNmw (ORCPT ); Fri, 17 Apr 2020 09:42:52 -0400 Received: by mail-wm1-f66.google.com with SMTP id x4so2977885wmj.1 for ; Fri, 17 Apr 2020 06:42:51 -0700 (PDT) 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:content-transfer-encoding :in-reply-to; bh=tOZKi29bbKZWeRD8Sxlu38LfstaUnzJU2Zc3Cur0xnM=; b=h+rlvybaJA+VNkmjptoomKUxP4BPxlgyEUvYZwOwrwyBET9clm/ym6zvfkHRT8GuEN vOS/VhOpeHgeml1mlk6/I+PKAG2rv7l2HGRLe1rSJH3PjWYJcI9tuzr+Y33hw/V58oOH TqJVvat0qghEx+K6sczI64YObTVN50t5tex0H8V/XYqZhmCRALmjjjjtGFJlLYeWxbDW tVzKvL1I4V6h1Ue9hhDHzE57QQs+E1xHqMRwnJHUNwBT+S+rcs7oB1ct3LQ/0y1qkFFT J+mgY4C36wZr14t56SXF2M7yPaD7iKbGMWKOgAwUxH4LYj7S0C0LB5RggIcQc5i3hLsl HOTg== X-Gm-Message-State: AGi0PuYWQtcPbjLJihPF8t7F6uiSmX68diubox0l0VuH1gpx+hDp73wE DsAe7quXe8kmYJFsjwPjwv8= X-Received: by 2002:a1c:808c:: with SMTP id b134mr3636797wmd.131.1587130969654; Fri, 17 Apr 2020 06:42:49 -0700 (PDT) Received: from localhost (ip-37-188-130-62.eurotel.cz. [37.188.130.62]) by smtp.gmail.com with ESMTPSA id i97sm33878249wri.1.2020.04.17.06.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2020 06:42:48 -0700 (PDT) Date: Fri, 17 Apr 2020 15:42:47 +0200 From: Michal Hocko To: =?utf-8?B?6LW15Yab5aWO?= Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel@vivo.com Subject: Re: Re: [PATCH] kmalloc_index optimization(add kmalloc max size check) Message-ID: <20200417134247.GN26707@dhcp22.suse.cz> References: <20200417113928.GL26707@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 17-04-20 20:17:19, 赵军奎 wrote: > > > From: Michal Hocko > Date: 2020-04-17 19:39:28 > To: Bernard Zhao > Cc: Christoph Lameter ,Pekka Enberg ,David Rientjes ,Joonsoo Kim ,Andrew Morton ,linux-mm@kvack.org,linux-kernel@vger.kernel.org,kernel@vivo.com > Subject: Re: [PATCH] kmalloc_index optimization(add kmalloc max size check)>On Fri 17-04-20 00:09:35, Bernard Zhao wrote: > >> kmalloc size should never exceed KMALLOC_MAX_SIZE. > >> kmalloc_index realise if size is exceed KMALLOC_MAX_SIZE, e.g 64M, > >> kmalloc_index just return index 26, but never check with OS`s max > >> kmalloc config KMALLOC_MAX_SIZE. This index`s kmalloc caches maybe > >> not create in function create_kmalloc_caches. > >> We can throw an warninginfo in kmalloc at the beginning, instead of > >> being guaranteed by the buddy alloc behind. > > > >I am sorry but I do not follow. What does this patch optimizes? AFAICS, > >it adds a branch for everybody for something that is highly unlikely > >usage. Btw. we already do handle those impossible cases. We could argue > >that BUG() is a bit harsh reaction but a lack of reports suggests this > >is not a real problem in fact. > > > >So what exactly do you want to achieve here? > > > > I'm not sure if my understanding has a gap. I think this should never happen. Yes. Have a look at the code and how all existing sizes map to an index with a BUG() fallback so this is already handled. As I've said the existing BUG() is far from optimal but a complete lack of bug reports hitting this mark suggests this path is not really triggered. And I do have objection to your patch. Because a) the description doesn't state the problem which it is fixing and b) the patch adds a test which everybody going this path has to evaluate and which should never trigger. So despite your subject line, there is no actual optimization but quite contrary. -- Michal Hocko SUSE Labs