Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp728283ybz; Fri, 17 Apr 2020 09:00:58 -0700 (PDT) X-Google-Smtp-Source: APiQypKDydnz6uWd7uDnANjogVMrNUY4HEcQffajsuOnQ2htC21WWGATLxN3AI+OaA0s9ZsFRtmC X-Received: by 2002:aa7:d64e:: with SMTP id v14mr3658997edr.19.1587139258467; Fri, 17 Apr 2020 09:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587139258; cv=none; d=google.com; s=arc-20160816; b=A5ww2waVnEwFlLaO2K9RpbqxCPezv4uMI0TC1IgOlAI8S/KbpsBv9jbP7Y0QNVEoFA 3eWCcsSEsVaoQSgfxku632A37QGpEw2nbDEjbeovHV54BuWUkOHem3+3EqjpIXaGssVy BH7xRX9XcnR/oAnY0jsaWGqzxQmZnL/409iBChWYdC6b+wRbrxZhqjzGPFRFaxH8UOqh 2QSmFxilrpSAtdXwm2SwO6jYJAPsHgtrqcKCnUdEfNkzV3r6IArbdtVUD+dm5SeWknU6 ls/yQTW+jCzhnMbBDJP/mN22x2w+ZIj91ysWRL+3Vwj4NBrK/y/xPG2OFvg2GN+oqJId CRyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=3DlzbxANOA607n1UUifmvu/bsq5/0CUWgz3+TM6OHYk=; b=uoZw/Ls+zxdlzycughdhFjgk8vEOelBE/gVWzPPlJh9kx61bHA/G3+LnxBFMhR9/v2 8QIo8bAw2NjMWBrOvTdT75Dc9/hp5BNB3UiTzmm362uCfe1eT+887w5aFCerCtVX7kUh TAPegmJVEG6FEPoMFP3m8p9EkI/rbXuJ8fZgFFxSOcsvlqRyEpalx3VNplqI23dtjzCX GD/qyKyFG7zeXD0BjE1fJzfoxRBreIiVVD2055IGcj54u67xJcc0ckjhL6gQhqQj3IE3 Vl9Rjhw190t8lSIM0zQZ3boukNG0cPqQLSWa20P9eAr/P3O2meMmskjYerDUjvVGkpDX 8KAg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn12si12134723ejc.52.2020.04.17.09.00.32; Fri, 17 Apr 2020 09:00:58 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729428AbgDQP7C (ORCPT + 99 others); Fri, 17 Apr 2020 11:59:02 -0400 Received: from gentwo.org ([3.19.106.255]:34904 "EHLO gentwo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbgDQP7B (ORCPT ); Fri, 17 Apr 2020 11:59:01 -0400 Received: by gentwo.org (Postfix, from userid 1002) id D03D83F9C5; Fri, 17 Apr 2020 15:59:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id CF7753E91E; Fri, 17 Apr 2020 15:59:00 +0000 (UTC) Date: Fri, 17 Apr 2020 15:59:00 +0000 (UTC) From: Christopher Lameter X-X-Sender: cl@www.lameter.com To: Bernard Zhao cc: 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) In-Reply-To: <1587107376-111722-1-git-send-email-bernard@vivo.com> Message-ID: References: <1587107376-111722-1-git-send-email-bernard@vivo.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 17 Apr 2020, 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. kmalloc_index(0 already bugs if the allocation is more than 64M ... if (size <= 64 * 1024 * 1024) return 26; BUG(); You could modify that to check for KMALLOC_MAX_SIZE with some more conditionals but then kmalloc_index) is written so that the compiler gets constant folding right. If you have a patch like that then please verify that all c compilers in use perform correct constant folding and do not add unnecessary code.