Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2319125pxb; Mon, 20 Sep 2021 18:42:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymAmec7hlHxRn3x18mF7TXsA8iVQfAEqQgXeN16oEhmhEc9ZVKe/2DxHVZkwbMNayYUCmV X-Received: by 2002:a6b:fd05:: with SMTP id c5mr21144751ioi.102.1632188520091; Mon, 20 Sep 2021 18:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188520; cv=none; d=google.com; s=arc-20160816; b=kWH6CD6eAJzhChwFvjw9NNXdIpO10SRXc7f60/AskXeuqtCfE1EkcjEFPIonWKtMIx zW68ERswhuw4dJFyF5/TtzqV2TbL6DhFf9X4yYW/PE3usx9Kyack4LqlKgpJKQwEmqyP /V5TECzkSrFNKIxhUH9bA1r/dHfGd3uyBDqquB8ghNVmFViUGf+kjQk3MWymEIePEHg3 jV+Ogynx/13TdoJuwuEQS38mzvANjqpsr4Ru8DlTtYoHQYYVjrRMSK72uJofZc3KfoQI DvNXqOBMg/jrsqdo3CqXax+72mAxUORafewLvsFHadAhyvNr390kqZG0j5udSfyyimJ2 77cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zcgflHwH//9l9NZVQhpNxx3+B3/idL/yTuch6m2kJcA=; b=nt6a0vh4Up1LIyybh1/nKcP0S5j7u2yuN3P5Up/qS4L9V6fYI0c/tZOXbmVAVijNgo 93JGzkpCQ2fh/rcb9v+h1Sdm0cogv13I4Fr7HO9W3+9pNm8ts4+1ca6pFxkzMvccn2pp r5YyvTSeNdSLv10AmSPLP0LnnEyYBEg8HzW+IotJFVjdMFyAh5lvtmXQ/mPxFzi+EX+C alCIx+qHJ9co5ZeXAum7I7187t/KeoEpJWff/Tu5LfQ8KqObAukBsac+O1Ufmr4wO3/a 4i9JploPEaQjs8EwuxQwQQiEhmFHyn8NiKOrqg//fYnBD2MJrAFoWTi6aGF3pS1aUzII QIDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BtlXErAy; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p14si5624006ils.122.2021.09.20.18.41.49; Mon, 20 Sep 2021 18:42:00 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BtlXErAy; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243670AbhITQsH (ORCPT + 99 others); Mon, 20 Sep 2021 12:48:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:35988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240451AbhITQri (ORCPT ); Mon, 20 Sep 2021 12:47:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5F62E61213; Mon, 20 Sep 2021 16:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156371; bh=lT9AcnaDFYupHCAPOGiNrpbNTJbT8jM7aaKkVAzgiuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BtlXErAynyK2OYFvjcs+dYwqsi5LUA2mEBa+f26me3ixagkoSrYHXjpAPquksA/vw eysNh2eob0A0SN/n1rIgb5QrqEJ82DPC985VHGFVva1tP7F4dyZdtw3vwkaJa2WSZs kv7Rey6xynnwD7sCRWHzmg3vsbt8d79DOiRJd5r0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Torvalds , Yisheng Xie , Catalin Marinas , Michal Hocko , Andrew Morton Subject: [PATCH 4.4 021/133] mm/kmemleak.c: make cond_resched() rate-limiting more efficient Date: Mon, 20 Sep 2021 18:41:39 +0200 Message-Id: <20210920163913.305406107@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163912.603434365@linuxfoundation.org> References: <20210920163912.603434365@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Morton commit 13ab183d138f607d885e995d625e58d47678bf97 upstream. Commit bde5f6bc68db ("kmemleak: add scheduling point to kmemleak_scan()") tries to rate-limit the frequency of cond_resched() calls, but does it in a way which might incur an expensive division operation in the inner loop. Simplify this. Fixes: bde5f6bc68db5 ("kmemleak: add scheduling point to kmemleak_scan()") Suggested-by: Linus Torvalds Cc: Yisheng Xie Cc: Catalin Marinas Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/kmemleak.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1394,7 +1394,7 @@ static void kmemleak_scan(void) if (page_count(page) == 0) continue; scan_block(page, page + 1, NULL); - if (!(pfn % (MAX_SCAN_SIZE / sizeof(*page)))) + if (!(pfn & 63)) cond_resched(); } }