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: 119219 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1191101vqm; Wed, 12 Jul 2023 07:30:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlHlv8G5BnqfxSxJ0TXzL7/YGMGjVresYyqSlYL4PSAhl/3XjVhdeXHgGjK24ECyHGq8L4qk X-Received: by 2002:a17:906:b88d:b0:970:71c:df58 with SMTP id hb13-20020a170906b88d00b00970071cdf58mr17405764ejb.42.1689172219476; Wed, 12 Jul 2023 07:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689172219; cv=none; d=google.com; s=arc-20160816; b=K15viOu/uCnl/eGKnouLPxlnvpoal3Wiut1Z02NQjlniK1XnFi17mZm5DUt72hL9fy h8aG3GeTkQFQlj9WX0P3FMjUznuMLFdbyBedDkKLuMqtDmQsAyEVOdRgmu3spD/w+PlB KO1we9sEvbsAnieGUv/R0TtVMG8BiXCmw2mWOpMrMD3ThO9X3veBNG6F0ZZohY/mKe4D 91KJBvcGZGotAFviF6i4fX5ksWyQbddCKJJ5Pu0pn74NJTvKBh2XLd5e9FPXwsxVIj05 FHQ6HE9Bj+F4r4t5mGbbTGt1e5wRq6kl9TAnIphyUkia5qj0iMpN//o7xSG1A+QsbJ+P /1rw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=AaYvLkQ+uQN/4z0R/trQTRcmsMOzJt2xdEyLPnUlQFs=; fh=FRon72YwFeIVU/LlfmPNxuVFiduvQKfa+Ydvnh8xLfc=; b=gWUF4tUUbOoQZBat69Y0IlQAJ5c7f4ov5YDCU3E71PUJrfgrigjKu+snHuuac5OhK3 96Orq4dt4HvRTQY2pbT2Yt0v8JOsS90Yi0ENoRnaTUtgxZbYowHH2pI67JcD6El+C5Vw BuuSTQd/E52vkVRk9IRqW7fcLum0f1l06Rpk9rmJHivhbKFG3lLA+l5qX2O+3+wVomGy /WLVzEU9LgKD+RQ8r7q2uMCe1t1GTupgGyVv4NWT7uj1Lg0XxMTauHu+wEe6HcMPjoe3 /iBSj3o0Tm4IzT8hPmklxKzTc5KZvVeEouWfHtOCg460603eu64tF/Y+qnOQfWEb047P x/SA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc5-20020a170906f90500b009931472bdb8si4527494ejb.965.2023.07.12.07.29.55; Wed, 12 Jul 2023 07:30:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232091AbjGLOZh (ORCPT + 99 others); Wed, 12 Jul 2023 10:25:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232448AbjGLOZW (ORCPT ); Wed, 12 Jul 2023 10:25:22 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D0E91BC5; Wed, 12 Jul 2023 07:25:17 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771225449392683140 X-GMAIL-MSGID: 1771225449392683140 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);