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); From patchwork Wed Jul 12 14:38:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 119229 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1202569vqm; Wed, 12 Jul 2023 07:49:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlEK6aDr/zTwKn5fI5BUCO6cop6Ag0jSVavIi3QFB/r2+OWCFSqz9wqKQDgrPnHGzROZlhNc X-Received: by 2002:ac2:58f4:0:b0:4f8:596a:4bb7 with SMTP id v20-20020ac258f4000000b004f8596a4bb7mr13617578lfo.57.1689173352047; Wed, 12 Jul 2023 07:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689173352; cv=none; d=google.com; s=arc-20160816; b=dWHfiCs5QuNkO+KPs35e6IangEdSh7y5YEajVaZEN8OGq0M+T/IVjngBSHLqvUsjhN J1cQTEdOEOG4xXyAz6/2AIctC7V+9OVzl34agfk72oJ8yL5+pAE6Zhil95bOM4TsO2hO zgPAyONGq602GPq9b3ISc41imNzBQQJiqd+1N1aVTpJLBpOR3WLaWnWdFedZvT7eERGk TFzJVYJfPJ+jedVsLUT26vCOc7qle+1QDPZIiMY5DbuLfX6JUOlgp3SM/CeFlUKbBH2m pVqYK52Pyfnee/o1yRgVId/jj1Hyp+LRrXFnsu16od7LhoIS9ULXzkybR6T/e5qj3yU+ PZTw== 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=i32xQsYNea2N3mRh+W5pA/MWZrgbJQEJwx4pUovWufk=; fh=FRon72YwFeIVU/LlfmPNxuVFiduvQKfa+Ydvnh8xLfc=; b=MlIY8mwPC1jwiBsvzaDw9OEQRqCl2P0+xw2o+yDg1fQaSMAOO8/nfBHUvxDeAmACCe EBRX7YQ4V2TmEDkZqk9Wm8EKaCT+7bpmibybUBZ3lrEScgHpl5vfBJ5ckyRuqqcQ9PAT K7HidIH9+KEzjJYDjpWypWUGJXRcUizKIppKmhhwlX3nXAUYPTjxPTXEpCNcGQzjJ1yv I9YTZ+j2n1ioiPCE8EqIwdHvTnqtjm61/dg1gWV6cUcLJLHNaX6LliySeLeM/zB2YSGJ gLeSYQw4weMGFR1CwJFaOQ7cN4j9F9JEJrSAZqQknwWMNgaJRotl/ebxEYMA4Kfu5ETW SlxA== 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 w10-20020aa7cb4a000000b0051e0ea53eafsi4734443edt.558.2023.07.12.07.48.47; Wed, 12 Jul 2023 07:49:12 -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 S232356AbjGLOZV (ORCPT + 99 others); Wed, 12 Jul 2023 10:25:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231827AbjGLOZU (ORCPT ); Wed, 12 Jul 2023 10:25:20 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72D7419A3; Wed, 12 Jul 2023 07:25:15 -0700 (PDT) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4R1KgS2xkDzMqYD; Wed, 12 Jul 2023 22:21:56 +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 2/5] mm: use vma_is_stack() and vma_is_heap() Date: Wed, 12 Jul 2023 22:38:28 +0800 Message-ID: <20230712143831.120701-3-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,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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: 1771226636993497920 X-GMAIL-MSGID: 1771226636993497920 Use the helpers to simplify code. Signed-off-by: Kefeng Wang --- fs/proc/task_mmu.c | 24 ++++-------------------- fs/proc/task_nommu.c | 15 +-------------- 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index cfab855fe7e9..05e9893552ce 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -236,21 +236,6 @@ static int do_maps_open(struct inode *inode, struct file *file, sizeof(struct proc_maps_private)); } -/* - * Indicate if the VMA is a stack for the given task; for - * /proc/PID/maps that is the stack of the main task. - */ -static int is_stack(struct vm_area_struct *vma) -{ - /* - * We make no effort to guess what a given thread considers to be - * its "stack". It's not even well-defined for programs written - * languages like Go. - */ - return vma->vm_start <= vma->vm_mm->start_stack && - vma->vm_end >= vma->vm_mm->start_stack; -} - static void show_vma_header_prefix(struct seq_file *m, unsigned long start, unsigned long end, vm_flags_t flags, unsigned long long pgoff, @@ -327,13 +312,12 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma) goto done; } - if (vma->vm_start <= mm->brk && - vma->vm_end >= mm->start_brk) { + if (vma_is_heap(vma)) { name = "[heap]"; goto done; } - if (is_stack(vma)) { + if (vma_is_stack(vma)) { name = "[stack]"; goto done; } @@ -1974,9 +1958,9 @@ static int show_numa_map(struct seq_file *m, void *v) if (file) { seq_puts(m, " file="); seq_file_path(m, file, "\n\t= "); - } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { + } else if (vma_is_heap(vma)) { seq_puts(m, " heap"); - } else if (is_stack(vma)) { + } else if (vma_is_stack(vma)) { seq_puts(m, " stack"); } diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index 2c8b62265981..f42c84172b9e 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c @@ -121,19 +121,6 @@ unsigned long task_statm(struct mm_struct *mm, return size; } -static int is_stack(struct vm_area_struct *vma) -{ - struct mm_struct *mm = vma->vm_mm; - - /* - * We make no effort to guess what a given thread considers to be - * its "stack". It's not even well-defined for programs written - * languages like Go. - */ - return vma->vm_start <= mm->start_stack && - vma->vm_end >= mm->start_stack; -} - /* * display a single VMA to a sequenced file */ @@ -171,7 +158,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma) if (file) { seq_pad(m, ' '); seq_file_path(m, file, ""); - } else if (mm && is_stack(vma)) { + } else if (mm && vma_is_stack(vma)) { seq_pad(m, ' '); seq_puts(m, "[stack]"); } From patchwork Wed Jul 12 14:38:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 119218 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1191088vqm; Wed, 12 Jul 2023 07:30:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlFHu69pzgza27vG51u8HiB9CZYCiGyMgGHZh5QfO6k7wj9mX/BIdQKptFNFfjmoc8bNinGL X-Received: by 2002:a17:906:20d7:b0:993:ec0b:1a21 with SMTP id c23-20020a17090620d700b00993ec0b1a21mr14076083ejc.27.1689172218540; Wed, 12 Jul 2023 07:30:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689172218; cv=none; d=google.com; s=arc-20160816; b=CvUF5DouW/NzbBiSasRB/DXnXZVPVhXbj7wCrsXtGKM+t7cxPgHH6KAgdZFhcefsiX FeG0mgWGDgMYUHgD7NEHl9FLNU2Xn5xU7RNGdqsZ9AFuKxoOVnSQbcIJV/MlTOGuCtMk Sb/3KTH0R1hWgoZByKx5pgmbGE83Du4X6qCtvLCOHENUInlKRWkeF2SLiqciwvwet5pY 7zLjCb5pULG7/JkE4JxgBRdUKrmcKXWWOT5941dtBAxMEwfr7Nt/Ufew1Cy2qGXiL2e1 ckpmI4q9/ylE1LFIqM1lFt4Ly6u3qYrTSpbunER5AL3uztxNlufJRj9zbqduzyg1sJKn e2pg== 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=ETNPB7wUh0SNwnx9DDYb/PlWZoZqHTNfB+0DsPV8JQI=; fh=FRon72YwFeIVU/LlfmPNxuVFiduvQKfa+Ydvnh8xLfc=; b=qnP0IK0NqCwUsOUCWLnBWuFoibAywwlQb2yxwn6at6tuesEKYjAC1w7CKKYlDhF7L1 hDmIU8nN1eNfQokFAf20OiwqN26WwBAax9uksryZyZ27IvSyCLXb0aQ1hrp1YMwoIIwS ftBsQ9dqmolLus9gyjBTV3drE1WASgJSsmeOEO2SFr7L9+pG+8ZqL0YPAubRIYdPu4jf eolntYaww4hUKosyzCA67ZzdPKuh5OXvhCyemS/0/Yg45JeqY3JaQv1jUDTJsQwXNzgp /0xAJj+gLFctYkECa/V4lpRie1nP9PP/+ynYdzUzZOscAkSTg465l/rRn4UFOpKSD74v Em5g== 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 sd1-20020a170906ce2100b00988a83822d8si4781865ejb.938.2023.07.12.07.29.53; Wed, 12 Jul 2023 07:30:18 -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 S232606AbjGLOZe (ORCPT + 99 others); Wed, 12 Jul 2023 10:25:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232441AbjGLOZW (ORCPT ); Wed, 12 Jul 2023 10:25:22 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6D491BC6; Wed, 12 Jul 2023 07:25:17 -0700 (PDT) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4R1Kkb0rdCz1JCP8; Wed, 12 Jul 2023 22:24:39 +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:13 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , , , Kefeng Wang Subject: [PATCH 3/5] drm/amdkfd: use vma_is_stack() and vma_is_heap() Date: Wed, 12 Jul 2023 22:38:29 +0800 Message-ID: <20230712143831.120701-4-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,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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: 1771225448275128502 X-GMAIL-MSGID: 1771225448275128502 Use the helpers to simplify code. Signed-off-by: Kefeng Wang --- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c index 479c4f66afa7..19ce68a7e1a8 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c @@ -2623,10 +2623,7 @@ svm_range_get_range_boundaries(struct kfd_process *p, int64_t addr, return -EFAULT; } - *is_heap_stack = (vma->vm_start <= vma->vm_mm->brk && - vma->vm_end >= vma->vm_mm->start_brk) || - (vma->vm_start <= vma->vm_mm->start_stack && - vma->vm_end >= vma->vm_mm->start_stack); + *is_heap_stack = vma_is_heap(vma) || vma_is_stack(vma); start_limit = max(vma->vm_start >> PAGE_SHIFT, (unsigned long)ALIGN_DOWN(addr, 2UL << 8)); From patchwork Wed Jul 12 14:38:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 119223 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1192331vqm; Wed, 12 Jul 2023 07:32:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlGnpe5gKtACXkpPPDYqLBiWrXQu3Kj3bA3Sx07PAnTVVwjlNoBR9qDFWdDmMWPo6Fa3Jynt X-Received: by 2002:a17:906:4792:b0:991:d5ad:f1a7 with SMTP id cw18-20020a170906479200b00991d5adf1a7mr24558792ejc.51.1689172328934; Wed, 12 Jul 2023 07:32:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689172328; cv=none; d=google.com; s=arc-20160816; b=QsXWEtaTysyYSWs2tZzYfNeWiz7vbrCZZOYiSNBAN/S1GyP1cII+2yHZc+U8AmCuA+ yQet9N/+mYBZLEXNBx9BS5PM0wByxy4ZTITjRAZyPROaXGu1g1P2UOBJY5rQ/1FK/iKo odVFlqPtzEIuAi60k25yrUuAbixbUzU3Dqqh1H+nzIEkuquGjw8DVuuQAUqtcjL74OgS us+qRsBvTDMvDc+Kaz8QqCk8MGa2ff/LADPHwdJNYg3GLnXsJ3hRigthF+15PIbZzH2v kvJ1uNFcT17ES/Q78NDo6K8T2NCDMOwcmg9KRxbyPehQ0iuwvfAUUuoD/1NeYryxghpH zUkA== 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=cog3zFED0zqk0ayh/5AST+3VWG2EFfyBo0064QrevtA=; fh=FRon72YwFeIVU/LlfmPNxuVFiduvQKfa+Ydvnh8xLfc=; b=nzL63ztNOed+mrhxHRb6tta3E2HAlYUsW/VhbNBAmFCFquQht/pVbc+ZZVSLxr+Jeq cQv9AtflZksex6tI7BjxIAGDv0WlP6Gi3NZDs9dQkFgo/LKEgj3HyamcI5IWGbHzULn2 CdRuNYBhyj9Eg0oKwpLqqYjr3wNmJ3F78Q1l7ShMKYYNyp0v9H57mDqrntaMc3TZ22k9 SdFPxm2GouUVUoG9AVg88k5FEgFDbizr4QN4UtOMfdjU/C1If9wYwXqIA2XSc8omu9Kf jNJGfgDcIt1i7XWC+TX0zdlCaGkPhGkLLCHdLxOAYEHEjJfMkUjgYaApvOe/6DD91UG7 SuvA== 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 b27-20020a170906491b00b00982a3005cf7si4374079ejq.605.2023.07.12.07.31.45; Wed, 12 Jul 2023 07:32:08 -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 S232187AbjGLOZ2 (ORCPT + 99 others); Wed, 12 Jul 2023 10:25:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232138AbjGLOZV (ORCPT ); Wed, 12 Jul 2023 10:25:21 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C4B619BE; Wed, 12 Jul 2023 07:25:16 -0700 (PDT) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4R1KhZ0q0bzPk8H; Wed, 12 Jul 2023 22:22:54 +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:13 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , , , Kefeng Wang Subject: [PATCH 4/5] selinux: use vma_is_stack() and vma_is_heap() Date: Wed, 12 Jul 2023 22:38:30 +0800 Message-ID: <20230712143831.120701-5-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: 1771225563603282975 X-GMAIL-MSGID: 1771225563603282975 Use the helpers to simplify code. Signed-off-by: Kefeng Wang Acked-by: Paul Moore --- security/selinux/hooks.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 4e46cf3d67b6..289ef2d6a427 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3775,13 +3775,10 @@ static int selinux_file_mprotect(struct vm_area_struct *vma, if (default_noexec && (prot & PROT_EXEC) && !(vma->vm_flags & VM_EXEC)) { int rc = 0; - if (vma->vm_start >= vma->vm_mm->start_brk && - vma->vm_end <= vma->vm_mm->brk) { + if (vma_is_heap(vma)) { rc = avc_has_perm(sid, sid, SECCLASS_PROCESS, PROCESS__EXECHEAP, NULL); - } else if (!vma->vm_file && - ((vma->vm_start <= vma->vm_mm->start_stack && - vma->vm_end >= vma->vm_mm->start_stack) || + } else if (!vma->vm_file && vma_is_stack(vma) || vma_is_stack_for_current(vma))) { rc = avc_has_perm(sid, sid, SECCLASS_PROCESS, PROCESS__EXECSTACK, NULL); From patchwork Wed Jul 12 14:38:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 119221 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1191614vqm; Wed, 12 Jul 2023 07:31:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlHNWVUMdgvOuhhIfGsW1Ikt74NKXRCmZ2wIbkR5W0t/1mUkXVO6mbD8zoGM6zQzWl8A4D9c X-Received: by 2002:a05:6a21:3292:b0:12f:3be3:f922 with SMTP id yt18-20020a056a21329200b0012f3be3f922mr19114130pzb.35.1689172267558; Wed, 12 Jul 2023 07:31:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689172267; cv=none; d=google.com; s=arc-20160816; b=JPT90s+7ePlG9N6lLirJKIzIFs/fp2SJcRN0w6SStt54Cr5FU0G5UwFCXHWEyRldgn pcdw1oFF0bqtYiiFPh7xPP6a4Yn+0m6ov6KppNBEmffF4j9jsjgn+f2d2j6EEzTHq5lV BWVSU6srvSAkORsnL8GV+IuGngZFqFBE7jVjZAjd7tgRIRbbPpdz8/WEpnzWPK7UU992 viuNXmUlZk2aS1kp7AnO72O6+0oTggY5UuN2UlbQljWMEMsgdcAyumaaF6U7oBfGGza1 PKIA+wJOpRLtnulUuSY5c4sX8sBEVYRz7r2u+t8XZzMhxg9s8XbP2arGlsY6oq+VVUPX bdgw== 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=4gJ3MZTpW0hnkqSksXaUK+M0JeoB0I0+1zt0kSd4N4g=; fh=FRon72YwFeIVU/LlfmPNxuVFiduvQKfa+Ydvnh8xLfc=; b=x/vd/o/xkh6g5DU91+1xBocMUn5hamzQAEl7VvKrq6Ge9mqYU0HAYgpYqlOv0N9ODk w9RCAGhgp3CDVVgCmL4NAaJTeHZqA1x6HaY4sMJvaJ5IX+tJf8X4C583d2oMzQqv+avi HYmILgIjaIH7kZmIQxp8jLEHIe8C37rBsSqxKVC2PN7CdCJWbuBAL57z5EJyVBFC02i9 M9yngucFwPhIKE7N/tUOgYEXOzn7HZSepIdF4Ar5B3qFJgTvDHkBsoP/Pm3wci9i1QXx 4l31vDKVQsXVclEXUF29zjpoRrq3zc9zjuxjzZsWE2WK32CnzQ8xB3TG7LOcwibTPsNG TZfg== 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 x71-20020a63864a000000b005575419ff14si3369593pgd.724.2023.07.12.07.30.41; Wed, 12 Jul 2023 07:31:07 -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 S232550AbjGLOZ3 (ORCPT + 99 others); Wed, 12 Jul 2023 10:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232359AbjGLOZW (ORCPT ); Wed, 12 Jul 2023 10:25:22 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33B541BC1; Wed, 12 Jul 2023 07:25:17 -0700 (PDT) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4R1Kkc0gYvz1JCRg; Wed, 12 Jul 2023 22:24:40 +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:14 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , , , Kefeng Wang Subject: [PATCH 5/5] perf/core: use vma_is_stack() and vma_is_heap() Date: Wed, 12 Jul 2023 22:38:31 +0800 Message-ID: <20230712143831.120701-6-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,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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: 1771225499849397472 X-GMAIL-MSGID: 1771225499849397472 Use the helpers to simplify code, also kill unneeded goto cpy_name. Signed-off-by: Kefeng Wang --- kernel/events/core.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 78ae7b6f90fd..cb271f449b81 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -8685,22 +8685,14 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event) } name = (char *)arch_vma_name(vma); - if (name) - goto cpy_name; - - if (vma->vm_start <= vma->vm_mm->start_brk && - vma->vm_end >= vma->vm_mm->brk) { - name = "[heap]"; - goto cpy_name; + if (!name) { + if (vma_is_heap(vma)) + name = "[heap]"; + else if (vma_is_stack(vma)) + name = "[stack]"; + else + name = "//anon"; } - if (vma->vm_start <= vma->vm_mm->start_stack && - vma->vm_end >= vma->vm_mm->start_stack) { - name = "[stack]"; - goto cpy_name; - } - - name = "//anon"; - goto cpy_name; } cpy_name: