From patchwork Wed Jul 12 14:38:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13310441 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 C80A9EB64DD for ; Wed, 12 Jul 2023 14:25:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 900726B0074; Wed, 12 Jul 2023 10:25:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A1D46B007B; Wed, 12 Jul 2023 10:25:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 690136B0074; Wed, 12 Jul 2023 10:25:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 489F86B0074 for ; Wed, 12 Jul 2023 10:25:23 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D0BA21402A7 for ; Wed, 12 Jul 2023 14:25:22 +0000 (UTC) X-FDA: 81003182484.14.D619071 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf24.hostedemail.com (Postfix) with ESMTP id 52E9F180021 for ; Wed, 12 Jul 2023 14:25:19 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689171920; a=rsa-sha256; cv=none; b=VukWvuARBZOA/5hNtQJy/8P0HiOUMe+fpQcknK4J+eOU2kAyFvKa+eVtaHNc+VqI21DXMH wsQb8ZG59QHESmV33bp8wVZquXEe6DbRl6t+VhOeV+RNbKTmlKdSDoihQw+bbGZ1wtTMgU 1uBkGAi00+FSWdeV2H6lyl4x0noIErY= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689171920; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AaYvLkQ+uQN/4z0R/trQTRcmsMOzJt2xdEyLPnUlQFs=; b=JizAJMKazrPRW+nVyAY44rMkeTaZum6VdGCB9/A67H/KKzSkoom0NQL4apJ1SN5WkM3h3m BJ9KoFPrApuBE+gkSkH2AWDxBm1m7/G2Pcaqqi8TT8V1LYXYr7nfWpSXrf3df+0LvJ3hQF P4c4ZB9Tmy9yo0IkAkknZM4Wq+deHno= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4R1KhX4dLLzPkCX; Wed, 12 Jul 2023 22:22:52 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 12 Jul 2023 22:25:12 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , , , Kefeng Wang Subject: [PATCH 1/5] mm: introduce vma_is_stack() and vma_is_heap() Date: Wed, 12 Jul 2023 22:38:27 +0800 Message-ID: <20230712143831.120701-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230712143831.120701-1-wangkefeng.wang@huawei.com> References: <20230712143831.120701-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 52E9F180021 X-Stat-Signature: s3ma4qwyr6towj8691d3hfdpc53amfhe X-Rspam-User: X-HE-Tag: 1689171919-91679 X-HE-Meta: U2FsdGVkX1/MtP499IVdIupM/SqjB9VWnvQLn6xHQMZC/Hl70fKWJQhBSrT9jUwCqZj+JD5FTHXVeY/WiEYxghP5fVyiLN+pNEZOfr13/quOB4KO2INj9BsquPeLnZ1cb+/v29SXHO0aB4fhPbjxl87UHlQ97Itiqc7gA0tVp5LEbJUa13OEEAKval8LvHzrNdfAz5mK7sGQN77l4Y9M+7YV/+rODfePfhb9HstNFtA9fkqzfcti2Im/m2ji1cXsqysCY2MRvWURTD9O4OserC2lnWGh/1JOnS7ABfKNardN3OCZZjlg8h7BmMxOxiZuUldYkvZ2zwcEQDoxYfxJyqEMbHAp/Gp7RQbrwbh1WmnDRBbI7NRsm7fc9xC40Q1MYeE64fko/2t0hdyS+GsLwXNOGbqrKJB0x7dIW/Nc1u4zRpwto/M4yk+A7HKGh6oNGWZGMIgOj5sDDyAZxtk2jNA1G/dS7yrt/V/cJ9nx3YCE3FP4PQ4t6laXbkaWoJ+ezPrVcfYWW8RQ0n5vqn/4JYsIb6dDETObw9Y4yc9agPgFR9YnignOPjdfwp6U76SdRtIausO+Ei5R4blRfem497VOvqE6vEP8W8gXTLuZAJcdPgWylbsyi8T/Wm5lwet47mXr07qnqEdixnzBENKHoL2MY70J5x7Qj74Ru4hg6+P39bMSoknfB5nfcZl535kHB3/YPliOEF+iwT+348EtSgyjtcG8eUruGYIJerjl169yE/jm37f7WpJDZbeNlIxhH039n8g80DeTCPGBt8U7cUe9Dxq31AgUFd4IeZav971D1+7FRGQMh7xJ56N938ahrtmppyXtmZVNmSAripXLJ283xpUoOsIiHxloEMvekk89hhGBHNc/7AtJMGHT3GZf7XPsg4OQaSSqkan2LFZRTDMcmoh2DXiTqZ7l3TP2GovmCPPrNSudRMnWHkVJei3kZYOyFtJqJBSnR41n2sU 5Usm2S55 4WTkSkuRrSIxuDtSulZe7BDl9h2QSo7A1+wE7Fz2EqvUEyZWrTBeCrTv7R0NVk+E9/1dhT4VqaYLaYL/GRzwKBilg/C+ZmHoFlLf9NyPeo0IpmOEUtOkksDeBwrCesWSVSlT8PS1gdWvUU1asAllkvM0axjA/DT5I1Qa2cMNiLAUbpzdgKKSkCiATLxW0hRZz11pr 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: Introduce the two helpers for general use. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 1462cf15badf..0bbeb31ac750 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -926,6 +926,18 @@ static inline bool vma_is_anonymous(struct vm_area_struct *vma) return !vma->vm_ops; } +static inline bool vma_is_heap(struct vm_area_struct *vma) +{ + return vma->vm_start <= vma->vm_mm->brk && + vma->vm_end >= vma->vm_mm->start_brk; +} + +static inline bool vma_is_stack(struct vm_area_struct *vma) +{ + return vma->vm_start <= vma->vm_mm->start_stack && + vma->vm_end >= vma->vm_mm->start_stack; +} + static inline bool vma_is_temporary_stack(struct vm_area_struct *vma) { int maybe_stack = vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP);