From patchwork Tue Jan 14 05:34:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Jiao X-Patchwork-Id: 13938430 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 9F5F7C02183 for ; Tue, 14 Jan 2025 05:36:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D89BF6B0083; Tue, 14 Jan 2025 00:36:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D3A0F6B0085; Tue, 14 Jan 2025 00:36:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB24F6B0088; Tue, 14 Jan 2025 00:36:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A25946B0083 for ; Tue, 14 Jan 2025 00:36:04 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 581571A05D3 for ; Tue, 14 Jan 2025 05:36:04 +0000 (UTC) X-FDA: 83004946248.15.12C2476 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by imf14.hostedemail.com (Postfix) with ESMTP id 225C4100005 for ; Tue, 14 Jan 2025 05:36:01 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=h4nA0eA4; spf=pass (imf14.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736832962; 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:dkim-signature; bh=qDL277UfuO/ZrvRomYA8juO/sG4dUYnxhYSbKtRIw2g=; b=Z0bGZcEWXuRgtG3KUQ2Qqy7KONBegHoePgRWJv9Mz5ivjSmL8mLWWeK4+46KP1oN9lwfQx N7usG61C/n5cv6aVWkjUjSFmXVgGrW4AM743QeEDtCEg3piAFFKaOD9WfYlVf3nNxZD/Cu BMJlrCXpdREiLrNXPl6GrS/VMfEe0ZQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736832962; a=rsa-sha256; cv=none; b=PVT2q/SZQeu7fROa/SrVAkEhZSwq4bot9g/wEKmqhrlqVa0MweQ8gHVTmdXGaFrAuHOOFn Q0DHnnmYwz6BMQG+rdciiTBmT1VEuqo4UUFHjB1PC0Gx6NeVBw0/5DmCsClr9ZHp7f9LQs YCGMJgJGZ/dPXLnWrlzSscb5KeSV/fM= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=h4nA0eA4; spf=pass (imf14.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50E2faK3019063; Tue, 14 Jan 2025 05:35:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= qDL277UfuO/ZrvRomYA8juO/sG4dUYnxhYSbKtRIw2g=; b=h4nA0eA4UEs6Tu4k wBfX7hgWFXXrnM+JGs+WebRVn7gpdPNJKHjYRSmkvrgEFV6N8C1Wtoo5mNH54CmU b5vckJfXnF6+ezglMfy/TK+YUxne1465BNOuXwxR17lz8k10fKU8kMC0l7QO2x5d Ym/yBCF6U5EKWI1tJvKVzF95OMKkz4P+ZQVKy7/TmkVpw0KC+MRsfGsiV7A0ivHk r8+MMeA1vSZ/O1nSBZZCnBrVcSIrKEHLwl22a8MgDFQsmp41YFwKkQhxWa4u6WEW 1sKZxzqy1COV3V0YYAqGHp5YoUMrXvPGWR++NEv6X6u4P8BKFkdxcxnJXkPWuoh+ 6SF9aw== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 445fc68ap7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:35:52 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 50E5ZpkU015485 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:35:51 GMT Received: from la-sh002-lnx.ap.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 13 Jan 2025 21:35:46 -0800 From: "Jiao, Joey" Date: Tue, 14 Jan 2025 13:34:31 +0800 Subject: [PATCH 1/7] kcov: introduce new kcov KCOV_TRACE_UNIQ_PC mode MIME-Version: 1.0 Message-ID: <20250114-kcov-v1-1-004294b931a2@quicinc.com> References: <20250114-kcov-v1-0-004294b931a2@quicinc.com> In-Reply-To: <20250114-kcov-v1-0-004294b931a2@quicinc.com> To: Dmitry Vyukov , Andrey Konovalov , Jonathan Corbet , Andrew Morton , Dennis Zhou , Tejun Heo , Christoph Lameter , Catalin Marinas , Will Deacon CC: , , , , , , X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1736832941; l=9637; i=quic_jiangenj@quicinc.com; s=20250114; h=from:subject:message-id; bh=B7wHQFKQobnmg8wdM6NUVeUWs1lU5h8VAiYZXhUuszQ=; b=3Fvg8y8dQ7utfwGWRCIqEI/3IwdHZiSSLCJAtwDZ3DSR+sj7AgVMY66KyCdxL52wgtcbIHf8o 9j75hRm567mDu2jxJ/jTIXR40Kjt9iqFT8hdyyzRUDAE3mZ2DSasfbM X-Developer-Key: i=quic_jiangenj@quicinc.com; a=ed25519; pk=JPzmfEvx11SW1Q1qtMhFcAx46KP1Ui36jcetDgbev28= X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: qeP3yiT5DpcBwuW5hL4M01mTLK8jZQWF X-Proofpoint-GUID: qeP3yiT5DpcBwuW5hL4M01mTLK8jZQWF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=777 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501140043 X-Rspamd-Queue-Id: 225C4100005 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: ks5nzi3cenychpcaqz8m6zm1sgeq7x93 X-HE-Tag: 1736832961-366870 X-HE-Meta: U2FsdGVkX19aiI1dDA1Wg6n431VccCDW6IIipK5NXHMXkhQ+VsMGSIsV4hxWG/KGNYRS4rt2nJDSrbn4v40nt9b5np3URt9BsUz/FrD2BxDj96PLF3yuH/zmYVuwnYc1trhJtJQR2D1SW9q1ra5EFKxsysfkSONF/qzSZVA5+Gnuw9SKSdOintwle9Bp9KFqMrdedHFhzJ5ovdDcoKWfZamETVguTVmKLSm4HXxWo8oFZmdTGNR2KcLrXs7D7D6WoecINB68s1JnNdEalNxScSMmqLie3zCvVaEbdCeON5hqneyNeMkV2hz4s4LzEiwoU1cDOriv30LIlym80k3Ues/WSnydVmitN6lzNTBbY+fSpEB21TXnC6kwo0hGO/TNyO8D9YL3JT5d9BodnUIOm30fQp33ROOke5002l7LxzF1Z5MB0f1Aie7OgPM4aE6qaIR61nARIuxrMKA+J3A4SAch3Ls1VmpSh6mzGxl/WQ63GilhmXF/8NJzV/TPQLbuvKHdrLNJZu6u8Hkyp9mCbXvSGivuGGneXeHGsHxyU0cO1Hu4gHrRvSn4HLLTgHwjsi4ciVCyn+x2nCtph7ODDD7ERfLiHGPFTgH0DRR94/7J6iGcwS3dKncJiNq7eCfuuqUy8qUcs4tQpS3n/Oy7n4eW/7tZravswbcrhRIdkfMcqf+gVKeI/zL2PPh4W5yUiavgPD55bHjWmszrMTNmsGpeAh37MYXYWe21YnGA1KaLA1m6qhtkJPRrwz8lzyDtVXiwlHY/MxTifUtvd2BjxFEVihmZAHCNuCIw2hhg/eR58KrtBmlAFMy7t+yZWSZemI5kSjZGRXDX+b3VZDHz2k3znEj2LGcP4KmBQ5cknBlQgHKL1/uAKYiTWNC/9QAo5PDJR4w0aEkuIAjomw9pVYZnnSySV/kgewbRFp8N48nokA6qx5EIwpdSRsOmI/6bK7qcKGm6xpypKtTVKTW ny9NLVH3 BkmtRFHuUP4XVWXQM+phe6E4vkZ6j0tTeT+lBYG9q2j3HTiinyRqRI3bnCClsrrkO64N3tS2UlO0vat2j1PsDRgzxWO8D/W/R470VVCycdKYdbWEzTefweLWDBuTY8T13ozk1T2YlezGROv3knW/cnmwSpLF681XqRp+3C3UOyhx7o8SGh122iDgEgpUXvW87IVW7igLWuPkuqz+olGKAI8C3hs533KHkuACxgVmSUra9n5msGfo7tbxjzKPiwySec+R28COgGbPPGp1Xvkk1yqmLTVScgU8ZQAeb5fem+qqZLxiyso3G+jrSt29I5KlGY471q/8Bxg1ehavpt8gC64SrfM+1TZZ58Zrongjagte0lpvb4MRTn3xKKg== 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: List-Subscribe: List-Unsubscribe: The current kcov KCOV_TRACE_PC mode stores PC in sequence. Introduce KCOV_TRACE_UNIQ_PC mode to store unique PC info. In unique PC mode, - use hashmap to store unique PC in kcov_entry - use gen_pool_alloc in __sanitizer_cov_trace_pc to avoid sleeping function kmalloc Signed-off-by: Jiao, Joey --- include/linux/kcov.h | 6 +- include/uapi/linux/kcov.h | 2 + kernel/kcov.c | 190 ++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 173 insertions(+), 25 deletions(-) diff --git a/include/linux/kcov.h b/include/linux/kcov.h index 75a2fb8b16c32917817b8ec7f5e45421793431ae..aafd9f88450cb8672c701349300b54662bc38079 100644 --- a/include/linux/kcov.h +++ b/include/linux/kcov.h @@ -20,9 +20,11 @@ enum kcov_mode { */ KCOV_MODE_TRACE_PC = 2, /* Collecting comparison operands mode. */ - KCOV_MODE_TRACE_CMP = 3, + KCOV_MODE_TRACE_CMP = 4, /* The process owns a KCOV remote reference. */ - KCOV_MODE_REMOTE = 4, + KCOV_MODE_REMOTE = 8, + /* COllecting uniq pc mode. */ + KCOV_MODE_TRACE_UNIQ_PC = 16, }; #define KCOV_IN_CTXSW (1 << 30) diff --git a/include/uapi/linux/kcov.h b/include/uapi/linux/kcov.h index ed95dba9fa37e291e9e9e0109eb8481bb7a5e9da..d2a2bff36f285a5e3a03395f8890fcb716cf3f07 100644 --- a/include/uapi/linux/kcov.h +++ b/include/uapi/linux/kcov.h @@ -35,6 +35,8 @@ enum { KCOV_TRACE_PC = 0, /* Collecting comparison operands mode. */ KCOV_TRACE_CMP = 1, + /* Collecting uniq PC mode. */ + KCOV_TRACE_UNIQ_PC = 2, }; /* diff --git a/kernel/kcov.c b/kernel/kcov.c index 28a6be6e64fdd721d49c4040ed10ce33f9d890a1..bbd7b7503206fe595976458ab685b95f784607d7 100644 --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -9,9 +9,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -32,6 +34,29 @@ /* Number of 64-bit words written per one comparison: */ #define KCOV_WORDS_PER_CMP 4 +struct kcov_entry { + unsigned long ent; + + struct hlist_node node; +}; + +/* Min gen pool alloc order. */ +#define MIN_POOL_ALLOC_ORDER ilog2(roundup_pow_of_two(sizeof(struct kcov_entry))) + +/* + * kcov hashmap to store uniq pc, prealloced mem for kcov_entry + * and area shared between kernel and userspace. + */ +struct kcov_map { + /* 15 bits fit most cases for hash collision, memory and performance. */ + DECLARE_HASHTABLE(buckets, 15); + struct gen_pool *pool; + /* Prealloced memory added to pool to be used as kcov_entry. */ + void *mem; + /* Buffer shared with user space. */ + void *area; +}; + /* * kcov descriptor (one per opened debugfs file). * State transitions of the descriptor: @@ -60,6 +85,8 @@ struct kcov { unsigned int size; /* Coverage buffer shared with user space. */ void *area; + /* Coverage hashmap for unique pc. */ + struct kcov_map *map; /* Task for which we collect coverage, or NULL. */ struct task_struct *t; /* Collecting coverage from remote (background) threads. */ @@ -171,7 +198,7 @@ static inline bool in_softirq_really(void) return in_serving_softirq() && !in_hardirq() && !in_nmi(); } -static notrace bool check_kcov_mode(enum kcov_mode needed_mode, struct task_struct *t) +static notrace unsigned int check_kcov_mode(enum kcov_mode needed_mode, struct task_struct *t) { unsigned int mode; @@ -191,7 +218,94 @@ static notrace bool check_kcov_mode(enum kcov_mode needed_mode, struct task_stru * kcov_start(). */ barrier(); - return mode == needed_mode; + return mode & needed_mode; +} + +static int kcov_map_init(struct kcov *kcov, unsigned long size) +{ + struct kcov_map *map; + void *area; + unsigned long flags; + + map = kzalloc(sizeof(*map), GFP_KERNEL); + if (!map) + return -ENOMEM; + + area = vmalloc_user(size * sizeof(unsigned long)); + if (!area) { + kfree(map); + return -ENOMEM; + } + + spin_lock_irqsave(&kcov->lock, flags); + map->area = area; + + kcov->map = map; + kcov->area = area; + spin_unlock_irqrestore(&kcov->lock, flags); + + hash_init(map->buckets); + + map->pool = gen_pool_create(MIN_POOL_ALLOC_ORDER, -1); + if (!map->pool) + return -ENOMEM; + + map->mem = vmalloc(size * (1 << MIN_POOL_ALLOC_ORDER)); + if (!map->mem) { + vfree(area); + gen_pool_destroy(map->pool); + kfree(map); + return -ENOMEM; + } + + if (gen_pool_add(map->pool, (unsigned long)map->mem, size * + (1 << MIN_POOL_ALLOC_ORDER), -1)) { + vfree(area); + vfree(map->mem); + gen_pool_destroy(map->pool); + kfree(map); + return -ENOMEM; + } + + return 0; +} + +static inline u32 hash_key(const struct kcov_entry *k) +{ + return jhash((u32 *)k, offsetof(struct kcov_entry, node), 0); +} + +static notrace inline void kcov_map_add(struct kcov_map *map, struct kcov_entry *ent, + struct task_struct *t) +{ + struct kcov *kcov; + struct kcov_entry *entry; + unsigned int key = hash_key(ent); + unsigned long pos, *area; + + kcov = t->kcov; + + hash_for_each_possible_rcu(map->buckets, entry, node, key) { + if (entry->ent == ent->ent) + return; + } + + entry = (struct kcov_entry *)gen_pool_alloc(map->pool, 1 << MIN_POOL_ALLOC_ORDER); + if (unlikely(!entry)) + return; + + barrier(); + memcpy(entry, ent, sizeof(*entry)); + hash_add_rcu(map->buckets, &entry->node, key); + + area = t->kcov_area; + + pos = READ_ONCE(area[0]) + 1; + if (likely(pos < t->kcov_size)) { + WRITE_ONCE(area[0], pos); + barrier(); + area[pos] = ent->ent; + } } static notrace unsigned long canonicalize_ip(unsigned long ip) @@ -212,25 +326,34 @@ void notrace __sanitizer_cov_trace_pc(void) unsigned long *area; unsigned long ip = canonicalize_ip(_RET_IP_); unsigned long pos; + struct kcov_entry entry = {0}; + unsigned int mode; t = current; - if (!check_kcov_mode(KCOV_MODE_TRACE_PC, t)) + if (!check_kcov_mode(KCOV_MODE_TRACE_PC | KCOV_MODE_TRACE_UNIQ_PC, t)) return; area = t->kcov_area; - /* The first 64-bit word is the number of subsequent PCs. */ - pos = READ_ONCE(area[0]) + 1; - if (likely(pos < t->kcov_size)) { - /* Previously we write pc before updating pos. However, some - * early interrupt code could bypass check_kcov_mode() check - * and invoke __sanitizer_cov_trace_pc(). If such interrupt is - * raised between writing pc and updating pos, the pc could be - * overitten by the recursive __sanitizer_cov_trace_pc(). - * Update pos before writing pc to avoid such interleaving. - */ - WRITE_ONCE(area[0], pos); - barrier(); - area[pos] = ip; + mode = t->kcov_mode; + if (mode == KCOV_MODE_TRACE_PC) { + area = t->kcov_area; + /* The first 64-bit word is the number of subsequent PCs. */ + pos = READ_ONCE(area[0]) + 1; + if (likely(pos < t->kcov_size)) { + /* Previously we write pc before updating pos. However, some + * early interrupt code could bypass check_kcov_mode() check + * and invoke __sanitizer_cov_trace_pc(). If such interrupt is + * raised between writing pc and updating pos, the pc could be + * overitten by the recursive __sanitizer_cov_trace_pc(). + * Update pos before writing pc to avoid such interleaving. + */ + WRITE_ONCE(area[0], pos); + barrier(); + area[pos] = ip; + } + } else { + entry.ent = ip; + kcov_map_add(t->kcov->map, &entry, t); } } EXPORT_SYMBOL(__sanitizer_cov_trace_pc); @@ -432,11 +555,33 @@ static void kcov_get(struct kcov *kcov) refcount_inc(&kcov->refcount); } +static void kcov_map_free(struct kcov *kcov) +{ + int bkt; + struct hlist_node *tmp; + struct kcov_entry *entry; + struct kcov_map *map; + + map = kcov->map; + if (!map) + return; + rcu_read_lock(); + hash_for_each_safe(map->buckets, bkt, tmp, entry, node) { + hash_del_rcu(&entry->node); + gen_pool_free(map->pool, (unsigned long)entry, 1 << MIN_POOL_ALLOC_ORDER); + } + rcu_read_unlock(); + vfree(map->area); + vfree(map->mem); + gen_pool_destroy(map->pool); + kfree(map); +} + static void kcov_put(struct kcov *kcov) { if (refcount_dec_and_test(&kcov->refcount)) { kcov_remote_reset(kcov); - vfree(kcov->area); + kcov_map_free(kcov); kfree(kcov); } } @@ -546,6 +691,8 @@ static int kcov_get_mode(unsigned long arg) #else return -ENOTSUPP; #endif + else if (arg == KCOV_TRACE_UNIQ_PC) + return KCOV_MODE_TRACE_UNIQ_PC; else return -EINVAL; } @@ -698,7 +845,6 @@ static long kcov_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) unsigned int remote_num_handles; unsigned long remote_arg_size; unsigned long size, flags; - void *area; kcov = filep->private_data; switch (cmd) { @@ -713,16 +859,14 @@ static long kcov_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) size = arg; if (size < 2 || size > INT_MAX / sizeof(unsigned long)) return -EINVAL; - area = vmalloc_user(size * sizeof(unsigned long)); - if (area == NULL) - return -ENOMEM; + res = kcov_map_init(kcov, size); + if (res) + return res; spin_lock_irqsave(&kcov->lock, flags); if (kcov->mode != KCOV_MODE_DISABLED) { spin_unlock_irqrestore(&kcov->lock, flags); - vfree(area); return -EBUSY; } - kcov->area = area; kcov->size = size; kcov->mode = KCOV_MODE_INIT; spin_unlock_irqrestore(&kcov->lock, flags); From patchwork Tue Jan 14 05:34:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Jiao X-Patchwork-Id: 13938431 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 E0695E77188 for ; Tue, 14 Jan 2025 05:36:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FBA16B008A; Tue, 14 Jan 2025 00:36:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6844C6B0089; Tue, 14 Jan 2025 00:36:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 487A76B008A; Tue, 14 Jan 2025 00:36:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 27CF96B0085 for ; Tue, 14 Jan 2025 00:36:08 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A7B3B1606D8 for ; Tue, 14 Jan 2025 05:36:07 +0000 (UTC) X-FDA: 83004946374.10.D874864 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf26.hostedemail.com (Postfix) with ESMTP id 4AE69140010 for ; Tue, 14 Jan 2025 05:36:05 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=jjgWv3xq; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf26.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736832965; a=rsa-sha256; cv=none; b=tliOtdwMhPX/uzPlmIeS80iG+/Y1f9hnQc5g3Qx4pcc5hcspTMcySaVe9r9kH+GmMiU3h7 9wtNkAG3v0LlawyNtjAFNo76SElrxBr5lZgPIFFEjF+zzhblSP+RUfF2fKijdNLYq84ffh I14CwCaqCfs+jXylQdQDJpSdT3qZdcA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=jjgWv3xq; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf26.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736832965; 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:dkim-signature; bh=ZBlk7f8TqoTzSTj9rN2g/BtOKJD+wVKUTcgd9+/bG5o=; b=DNWQMv1sESi05Ks01GPMi7dNw3shGNhrKi+iPB5U2a7canjxeqilfEXX8t73QCnxtcZ9n+ vlVSUPXNib8B8uiVemGqbBnw/RR7zWMdGALjHursCkPMCP1DbSqBpM/shZ1fnqPKGzPGjN RUPseo1IBmWffWeT3H1JvawFgexqB/g= Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50DKsOnq026165; Tue, 14 Jan 2025 05:35:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= ZBlk7f8TqoTzSTj9rN2g/BtOKJD+wVKUTcgd9+/bG5o=; b=jjgWv3xqg/L/e6Uo AC9koJ2vVx9qp+MOxby5ntqzJyl0t4sN+iJH7F+MitXJEnoPQTTTUF8FWPdgpyfG nmRmCe5zMMpuXNDjldrt9ZRfgbc4K+IXR4JV1Dju1Lbji7Va4g/aK5Ur21ZtFrTA y+VLaeSLn9s9YIWPiZEtwt1mhbGfJYMkKpYSwbhBIxmOfMNQGr7v8RPnMAUPQOAz GyvMwdFGp6bYQapq+o0ALxLzjE7JaGQovBEWY3eaz+izjXycBFCus5vKRXGkq+7n ShZx0lMOufzrKVPJC/P1Xh/GQ8vIyxWnQb5PTKDNcGPNUwNOCZ2SZdo4OLwn8NNW w4FtSw== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 445a928wyk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:35:55 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 50E5ZtXN019909 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:35:55 GMT Received: from la-sh002-lnx.ap.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 13 Jan 2025 21:35:49 -0800 From: "Jiao, Joey" Date: Tue, 14 Jan 2025 13:34:32 +0800 Subject: [PATCH 2/7] kcov: introduce new kcov KCOV_TRACE_UNIQ_EDGE mode MIME-Version: 1.0 Message-ID: <20250114-kcov-v1-2-004294b931a2@quicinc.com> References: <20250114-kcov-v1-0-004294b931a2@quicinc.com> In-Reply-To: <20250114-kcov-v1-0-004294b931a2@quicinc.com> To: Dmitry Vyukov , Andrey Konovalov , Jonathan Corbet , Andrew Morton , Dennis Zhou , Tejun Heo , Christoph Lameter , Catalin Marinas , Will Deacon CC: , , , , , , X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1736832942; l=7640; i=quic_jiangenj@quicinc.com; s=20250114; h=from:subject:message-id; bh=fvIA7qPV+F40Lv2i0NOI93SQe1UCKicXtboCEOT2WIE=; b=kUJuqBf1WmXlkxHJKhCifPFT0HbTOCIQVzM7sdSklSI6WvFaFMlQeqx5N+zeSQr1xFpBOVsHQ FNLdRqhqeubCMcg5KCoYN8gH6gRE5trVbdd0mTyeNPGbGPsxiea0tMG X-Developer-Key: i=quic_jiangenj@quicinc.com; a=ed25519; pk=JPzmfEvx11SW1Q1qtMhFcAx46KP1Ui36jcetDgbev28= X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: YQARHycxSoqmMiVizCvzkbVFl1mo40vy X-Proofpoint-ORIG-GUID: YQARHycxSoqmMiVizCvzkbVFl1mo40vy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 suspectscore=0 impostorscore=0 adultscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=999 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501140044 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 4AE69140010 X-Stat-Signature: ts6ns7hqbj34gg1cac66wpnweu444hnz X-Rspam-User: X-HE-Tag: 1736832965-793536 X-HE-Meta: U2FsdGVkX19kNOOLASBKkmoVw8oQNVJZW9PSvrV0Xsl3z26ePJId6URhMNwWxky2POD6effbE/DQfxZmkfoJGigHI3tm4I/lO1/ckWs9W5PnuYSEzdJpu5TG7akq0O58T1lMgjUUQoWTuDPP+MzeWdOIqO3gEQj2R79t5modbq073XR4vlOAbxN3oflfV8NCmXkJ6ThyUSkF3HNhxDlcivuBV9gBWzDVkuF0ZZV+R4LFoY04nz4AIRiNAJB8IOnlCtf2bMwoErIA+U6hj6qI3xzfNE7QX52T+L+J3wW23ZqiMSDLzqgxXAhLafi17uPLkgcV+7qN3ZiHjcl0iSAyLfIKhEHETTRWAbdXLAHNq5u3/i5FsGEdMniMcULH4W8Q1et8/I5lPlmi0aKthwq2USRssYS6XWAYYJQ9aUmIguK5N/eLycap/VABy2R71KjIJuVCWQjz4vSCb3I82GRzPS8jevbfVPMjdDqjBdOoV5kj7aqb2yCA1KkQA2HNxBHGnqj/iSBwliBoZpVKEyMQpyyA4usFyOPfk2znOqipXBr0gYOLf7vxeSTA/Pm6y8GEvqBPhYXdk5a0HHbzHluI+MR27lT+1aTUo9C+BtUW+uN9OneBZIOnvHEiCcVpQ+19N/ohuS22/pMhClTAY7dffYd76dhmy2VgV3PGMTCn66bwRKx7ZUfG+mZZ15Y13x5R3Yiq5cGCSMvu+PjXp7sgNsXG3oK4EzXDf/V8DyawQcWJanfgTS9/kLrm4Br3pcRmo4GgGdxpSa7ohB7rm9O2axIMsw+94vQwTPVzul1bYkpwb36LK2x8eS0l+TZy4CZ8gGOgb9zr8i5YvYIUANmm10x2clyvzIpW56FupdGrPt+TcPE+z04Q+1o8KAkOew0h4O0FXCUsHxBpTIPrZd1n7br8IA0D0Y3gzuIKpj0Urbfmwkpx5KsJhPs1RTH20t7BlnPTKU8k5DNSdj7QSxQ sDSZrGrN ED6LZdumzlDZ27NccjXMV+CR/8LExAlK9AycaSSULBaOPjs4gSkJ86CgHC+mPuWnh9b1xosf8Q3EjOfWJA+e3NgeVM5n2eRmJLjJEMWbYU7IWwISzj4o7QNUVxGso3TFnVqFhHZPEDvtwdR64nelYQHmpy/QCEzeDpbXlm6x2lgToHauWalzhGFtn6joEIGe1ATD4vmu8tlWQZiPqmTxmgoZhaINLdRugj2jN3m+5Me3a/HY+NrCL3UnstjIfbGk+IzieLNWYVxhVGECfKzhhxL0GEy8WAH5bJn2sBdovE0TuPF1NuAUPCHCgZBGHXaj/VkulIImyu+4BIhM+rok8ilkraUd0wah8yWZvVmvJu0VeQgILy9bkWoCJwg== 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: List-Subscribe: List-Unsubscribe: KCOV_TRACE_UNIQ_EDGE stores uniq edge info, which is bitwise xor operation of prev_pc and current pc. And only hash the lower 12 bits so the hash is independent of any module offsets. Signed-off-by: Jiao, Joey --- include/linux/kcov.h | 4 ++- include/uapi/linux/kcov.h | 2 ++ kernel/kcov.c | 73 ++++++++++++++++++++++++++++++++++++----------- 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/include/linux/kcov.h b/include/linux/kcov.h index aafd9f88450cb8672c701349300b54662bc38079..56b858205ba16c47fc72bda9938c98f034503c8c 100644 --- a/include/linux/kcov.h +++ b/include/linux/kcov.h @@ -23,8 +23,10 @@ enum kcov_mode { KCOV_MODE_TRACE_CMP = 4, /* The process owns a KCOV remote reference. */ KCOV_MODE_REMOTE = 8, - /* COllecting uniq pc mode. */ + /* Collecting uniq pc mode. */ KCOV_MODE_TRACE_UNIQ_PC = 16, + /* Collecting uniq edge mode. */ + KCOV_MODE_TRACE_UNIQ_EDGE = 32, }; #define KCOV_IN_CTXSW (1 << 30) diff --git a/include/uapi/linux/kcov.h b/include/uapi/linux/kcov.h index d2a2bff36f285a5e3a03395f8890fcb716cf3f07..9b2019f0ab8b8cb5426d2d6b74472fa1a7293817 100644 --- a/include/uapi/linux/kcov.h +++ b/include/uapi/linux/kcov.h @@ -37,6 +37,8 @@ enum { KCOV_TRACE_CMP = 1, /* Collecting uniq PC mode. */ KCOV_TRACE_UNIQ_PC = 2, + /* Collecting uniq edge mode. */ + KCOV_TRACE_UNIQ_EDGE = 4, }; /* diff --git a/kernel/kcov.c b/kernel/kcov.c index bbd7b7503206fe595976458ab685b95f784607d7..5a0ead92729294d99db80bb4e0f5b04c8b025dba 100644 --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -83,10 +83,14 @@ struct kcov { enum kcov_mode mode; /* Size of arena (in long's). */ unsigned int size; + /* Previous PC. */ + unsigned long prev_pc; /* Coverage buffer shared with user space. */ void *area; /* Coverage hashmap for unique pc. */ struct kcov_map *map; + /* Edge hashmap for unique edge. */ + struct kcov_map *map_edge; /* Task for which we collect coverage, or NULL. */ struct task_struct *t; /* Collecting coverage from remote (background) threads. */ @@ -221,7 +225,7 @@ static notrace unsigned int check_kcov_mode(enum kcov_mode needed_mode, struct t return mode & needed_mode; } -static int kcov_map_init(struct kcov *kcov, unsigned long size) +static int kcov_map_init(struct kcov *kcov, unsigned long size, bool edge) { struct kcov_map *map; void *area; @@ -240,8 +244,12 @@ static int kcov_map_init(struct kcov *kcov, unsigned long size) spin_lock_irqsave(&kcov->lock, flags); map->area = area; - kcov->map = map; - kcov->area = area; + if (edge) { + kcov->map_edge = map; + } else { + kcov->map = map; + kcov->area = area; + } spin_unlock_irqrestore(&kcov->lock, flags); hash_init(map->buckets); @@ -276,7 +284,7 @@ static inline u32 hash_key(const struct kcov_entry *k) } static notrace inline void kcov_map_add(struct kcov_map *map, struct kcov_entry *ent, - struct task_struct *t) + struct task_struct *t, unsigned int mode) { struct kcov *kcov; struct kcov_entry *entry; @@ -298,7 +306,10 @@ static notrace inline void kcov_map_add(struct kcov_map *map, struct kcov_entry memcpy(entry, ent, sizeof(*entry)); hash_add_rcu(map->buckets, &entry->node, key); - area = t->kcov_area; + if (mode == KCOV_MODE_TRACE_UNIQ_PC) + area = t->kcov_area; + else + area = kcov->map_edge->area; pos = READ_ONCE(area[0]) + 1; if (likely(pos < t->kcov_size)) { @@ -327,13 +338,15 @@ void notrace __sanitizer_cov_trace_pc(void) unsigned long ip = canonicalize_ip(_RET_IP_); unsigned long pos; struct kcov_entry entry = {0}; + /* Only hash the lower 12 bits so the hash is independent of any module offsets. */ + unsigned long mask = (1 << 12) - 1; unsigned int mode; t = current; - if (!check_kcov_mode(KCOV_MODE_TRACE_PC | KCOV_MODE_TRACE_UNIQ_PC, t)) + if (!check_kcov_mode(KCOV_MODE_TRACE_PC | KCOV_MODE_TRACE_UNIQ_PC | + KCOV_MODE_TRACE_UNIQ_EDGE, t)) return; - area = t->kcov_area; mode = t->kcov_mode; if (mode == KCOV_MODE_TRACE_PC) { area = t->kcov_area; @@ -352,8 +365,15 @@ void notrace __sanitizer_cov_trace_pc(void) area[pos] = ip; } } else { - entry.ent = ip; - kcov_map_add(t->kcov->map, &entry, t); + if (mode & KCOV_MODE_TRACE_UNIQ_PC) { + entry.ent = ip; + kcov_map_add(t->kcov->map, &entry, t, KCOV_MODE_TRACE_UNIQ_PC); + } + if (mode & KCOV_MODE_TRACE_UNIQ_EDGE) { + entry.ent = (hash_long(t->kcov->prev_pc & mask, BITS_PER_LONG) & mask) ^ ip; + t->kcov->prev_pc = ip; + kcov_map_add(t->kcov->map_edge, &entry, t, KCOV_MODE_TRACE_UNIQ_EDGE); + } } } EXPORT_SYMBOL(__sanitizer_cov_trace_pc); @@ -555,14 +575,17 @@ static void kcov_get(struct kcov *kcov) refcount_inc(&kcov->refcount); } -static void kcov_map_free(struct kcov *kcov) +static void kcov_map_free(struct kcov *kcov, bool edge) { int bkt; struct hlist_node *tmp; struct kcov_entry *entry; struct kcov_map *map; - map = kcov->map; + if (edge) + map = kcov->map_edge; + else + map = kcov->map; if (!map) return; rcu_read_lock(); @@ -581,7 +604,8 @@ static void kcov_put(struct kcov *kcov) { if (refcount_dec_and_test(&kcov->refcount)) { kcov_remote_reset(kcov); - kcov_map_free(kcov); + kcov_map_free(kcov, false); + kcov_map_free(kcov, true); kfree(kcov); } } @@ -636,18 +660,27 @@ static int kcov_mmap(struct file *filep, struct vm_area_struct *vma) unsigned long size, off; struct page *page; unsigned long flags; + void *area; spin_lock_irqsave(&kcov->lock, flags); size = kcov->size * sizeof(unsigned long); - if (kcov->area == NULL || vma->vm_pgoff != 0 || - vma->vm_end - vma->vm_start != size) { + if (!vma->vm_pgoff) { + area = kcov->area; + } else if (vma->vm_pgoff == size >> PAGE_SHIFT) { + area = kcov->map_edge->area; + } else { + spin_unlock_irqrestore(&kcov->lock, flags); + return -EINVAL; + } + + if (!area || vma->vm_end - vma->vm_start != size) { res = -EINVAL; goto exit; } spin_unlock_irqrestore(&kcov->lock, flags); vm_flags_set(vma, VM_DONTEXPAND); for (off = 0; off < size; off += PAGE_SIZE) { - page = vmalloc_to_page(kcov->area + off); + page = vmalloc_to_page(area + off); res = vm_insert_page(vma, vma->vm_start + off, page); if (res) { pr_warn_once("kcov: vm_insert_page() failed\n"); @@ -693,6 +726,8 @@ static int kcov_get_mode(unsigned long arg) #endif else if (arg == KCOV_TRACE_UNIQ_PC) return KCOV_MODE_TRACE_UNIQ_PC; + else if (arg == KCOV_TRACE_UNIQ_EDGE) + return KCOV_MODE_TRACE_UNIQ_EDGE; else return -EINVAL; } @@ -747,7 +782,8 @@ static int kcov_ioctl_locked(struct kcov *kcov, unsigned int cmd, * at task exit or voluntary by KCOV_DISABLE. After that it can * be enabled for another task. */ - if (kcov->mode != KCOV_MODE_INIT || !kcov->area) + if (kcov->mode != KCOV_MODE_INIT || !kcov->area || + !kcov->map_edge->area) return -EINVAL; t = current; if (kcov->t != NULL || t->kcov != NULL) @@ -859,7 +895,10 @@ static long kcov_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) size = arg; if (size < 2 || size > INT_MAX / sizeof(unsigned long)) return -EINVAL; - res = kcov_map_init(kcov, size); + res = kcov_map_init(kcov, size, false); + if (res) + return res; + res = kcov_map_init(kcov, size, true); if (res) return res; spin_lock_irqsave(&kcov->lock, flags); From patchwork Tue Jan 14 05:34:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Jiao X-Patchwork-Id: 13938432 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 65D3CC02183 for ; Tue, 14 Jan 2025 05:36:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC4666B0089; Tue, 14 Jan 2025 00:36:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E264E6B008C; Tue, 14 Jan 2025 00:36:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2A946B0092; Tue, 14 Jan 2025 00:36:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 963C26B0089 for ; Tue, 14 Jan 2025 00:36:10 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5800F1C724E for ; Tue, 14 Jan 2025 05:36:10 +0000 (UTC) X-FDA: 83004946500.30.E65C07D Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by imf26.hostedemail.com (Postfix) with ESMTP id 2822614000E for ; Tue, 14 Jan 2025 05:36:07 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=aXbBkGUg; spf=pass (imf26.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736832968; 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:dkim-signature; bh=CFVY0tjOmtO4qAqPnzy1tUQpQ6ETWmPtYq/HPU3qSi0=; b=zG1mi4cBCVEkWVzPMB3NU1KIyojBlcUluYtOW0e2fwc7EXKk4ofNJxN3LsNZ1ssjher+ol Ko+MpVhKLJHf3KveSFI5/HhWcNuS4D1B126nKyPb/w4bYleYTzpboxDZfwSZWDZpiHfiUJ XmjRz9xJMQ3SZyH7e1CZGRx6n6pC7A0= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=aXbBkGUg; spf=pass (imf26.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736832968; a=rsa-sha256; cv=none; b=CDAJE1ic9HLITOBEfFADdDKtSI46GQZEia6bBNM/qs9TEwoDfcJgEm27Tg6FlPSzTzNENr 9GGHsqP7scKKpudpuX23O+IJyllq5sJ0SnbhYnoPa3te4mVM6WB24jKvb+qQDApZQsUmRc mKUObg6KR1JsPgJe5M7lE1Gx894g94E= Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50E2fc3u019144; Tue, 14 Jan 2025 05:35:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= CFVY0tjOmtO4qAqPnzy1tUQpQ6ETWmPtYq/HPU3qSi0=; b=aXbBkGUgRenYY+kr GhmhQxZFugwhs7ZerU+nCDz07oNXy4dB4IsS2Dn6ffnsRAFAHFmCulqCfnvn0VZR bIytfkOm3h0P5hnNhe8KtDRHc8NH8eI9DlQNPjFbr8uU61jzSSWI8lo63KxdwObG g+W8U0oLtB92OF40g3tTxMK1mz7UYvFQ8oMYPZrIgS+gcyD4nqoVAm9Gz6kFruCF s4DxNhbl1OReEc6X2stwMw0UD7kOwcqAU55wLJ0gHbGVK0i5TF/P7V49jaVzrFOQ HtJqJkcvB2YAuVoH74/8hjKc+QzkWFrpur5WdJVKmG7EukAMBxVk0586B5vLzQkx lXQJPQ== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 445fc68apd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:35:59 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 50E5Zwtu020376 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:35:58 GMT Received: from la-sh002-lnx.ap.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 13 Jan 2025 21:35:52 -0800 From: "Jiao, Joey" Date: Tue, 14 Jan 2025 13:34:33 +0800 Subject: [PATCH 3/7] kcov: allow using KCOV_TRACE_UNIQ_[PC|EDGE] modes together MIME-Version: 1.0 Message-ID: <20250114-kcov-v1-3-004294b931a2@quicinc.com> References: <20250114-kcov-v1-0-004294b931a2@quicinc.com> In-Reply-To: <20250114-kcov-v1-0-004294b931a2@quicinc.com> To: Dmitry Vyukov , Andrey Konovalov , Jonathan Corbet , Andrew Morton , Dennis Zhou , Tejun Heo , Christoph Lameter , Catalin Marinas , Will Deacon CC: , , , , , , X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1736832942; l=1250; i=quic_jiangenj@quicinc.com; s=20250114; h=from:subject:message-id; bh=cUrFJ9xlku6iOVJmqRm3AKSPyxlxbIELfrHlRVSE678=; b=PN4imkwKcD7/nAryYV3lJaq77IA4e+9rhwFDEIua2TPoylFR2tEVvYzX1A0kElet197HOJhRv KnL6OAxKhzVAAeMfHluhR5AD/KnczeQvktL1Pe8Wg8BhWFmOtiquMjy X-Developer-Key: i=quic_jiangenj@quicinc.com; a=ed25519; pk=JPzmfEvx11SW1Q1qtMhFcAx46KP1Ui36jcetDgbev28= X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 2ybqo6M8sHxWZsrwE_g4pZ5-4RN20TNw X-Proofpoint-GUID: 2ybqo6M8sHxWZsrwE_g4pZ5-4RN20TNw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=891 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501140043 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2822614000E X-Rspam-User: X-Stat-Signature: hfk8x5w4znjmf9u5yarzh1cps6gu1h4o X-HE-Tag: 1736832967-16218 X-HE-Meta: U2FsdGVkX1/3vUA6HXj2jvsXtiC2tdJEI4vLwaxNuKgqyAdxm4x47kGIdZMjjcX7moNP3DcmfpD4O4a/OpYYhs5M2+WTkj9Yqz6tj4MmT6fh9R86Zf+5YiOySY/VjeXoKCvwCn7WX6z8oVbxosvGK23DcGcrEE4iLe4YEHUHnbLEUaRtmHRQbWSBADdvagn8x8trinNFur8ODv7xwqjhVXDnCZYNM72DDI5Nr3eIAYmegUTU2HGzY+Xw4X4iN4MAV23HHqvVfgxjpJmA3TuNrni24lVOUxIyhzlqORBMBtOrMJ2PwZ8ld46oEnsx3W15e0umX0XIPgIe64GiJYB37YeFvYwJZBtFPqoqSOmUHynWjt8gXA/U7BpGR8mtE8MUs9kLF7e/OS+/K8R5HFOFYHBh2Cgpdf79NUL2/NKGjoW+Fw7NfwccN/kLGt/a2BUsJ7cnttpMLaEotqNlyCW0mO4LHJ2cNxA6tGd+e/PWETIdC1FcCQZAYVDa/FXgnkR+YUd/bw031726o1hbRojM0uPagfOgSGJ7yV1hbhLlrK/QQI2HUFPrMosVEUlL+24cnRZ/TYijv9T6i4ejYLtfyjSgVjsE/TK0lEPqEbLtq9HRxEouZO7T+VOfq5FTcqVB29RJM/0e/Fne1zBLLklDrdkB1DHeWK2xPjsSh5mGQjzhQLRR/DEIgQmCLcQXnm08XCkWCJpd4qnwjIiqlyfHOBuHUIpymSU8BwF9vEhMEyJn+XrSxwEpPgF5NPudv/lBWsqrMd88iOw+fsgbi5dBEQddK+zJbau0cX76LdrlbbFyh99314a+UouYz2NhchrY55FpRyFTxBSt+bDiKz8gqMsFGUp/yJkv2RgKo37AVRRzpHPiJxSGIcprL3r7bJpnuzeYK3Vz1WUZDglpjiWHjeMSrG6GeW+rX6c6Jc+3evFn6k/sMMM5IPyfzIvD7d891Zjb3mYffZtlXQ5hK7f iwpwnQeZ elIQs8xEZkzzY7GC42oS3RI3DUgbx9XUBN0UR+hm/DQaPlAiX/smDdMtxmoPYXIq38Ajcvz+MqC8oI5BefxXovC9EYZjGzvzZcM7OJeGT6MRTUrkkbXahPC4Tyjds6oORgIi6HUsx7Jar2A3nAzGMVt14LKXhhzxZb1sJYo2SrseNDkPHKGO7ZxcMVyNori77rej7No3aYNkoN2uMXjL7RQI0Ccru/IL2ftDNdTAUsOA6cTJSVgpQzVm6BFKgKqtzK6cNwKu5e9QSSIQtbtPy8JdKBP1a4iH/CKXLkZgDdGyxhPjdEiBe8nCPc5+9cBq1VlKSzVSS+wrYv0KlvP7fzjtE3sH1MGUcqyjQQhDFZd5v635TW68Wovl8vw== 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: List-Subscribe: List-Unsubscribe: KCOV_TRACE_UNIQ_PC and KCOV_TRACE_UNIQ_EDGE modes can be used separately, and now they can be used together to simulate current KCOV_TRACE_PC mode without sequence info. Signed-off-by: Jiao, Joey --- kernel/kcov.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/kernel/kcov.c b/kernel/kcov.c index 5a0ead92729294d99db80bb4e0f5b04c8b025dba..c04bbec9ac3186a5145240de8ac609ad8a7ca733 100644 --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -716,6 +716,8 @@ static int kcov_close(struct inode *inode, struct file *filep) static int kcov_get_mode(unsigned long arg) { + int mode = 0; + if (arg == KCOV_TRACE_PC) return KCOV_MODE_TRACE_PC; else if (arg == KCOV_TRACE_CMP) @@ -724,12 +726,14 @@ static int kcov_get_mode(unsigned long arg) #else return -ENOTSUPP; #endif - else if (arg == KCOV_TRACE_UNIQ_PC) - return KCOV_MODE_TRACE_UNIQ_PC; - else if (arg == KCOV_TRACE_UNIQ_EDGE) - return KCOV_MODE_TRACE_UNIQ_EDGE; - else + if (arg & KCOV_TRACE_UNIQ_PC) + mode |= KCOV_MODE_TRACE_UNIQ_PC; + if (arg & KCOV_TRACE_UNIQ_EDGE) + mode |= KCOV_MODE_TRACE_UNIQ_EDGE; + if (!mode) return -EINVAL; + + return mode; } /* From patchwork Tue Jan 14 05:34:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Jiao X-Patchwork-Id: 13938433 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 2C0B8E77188 for ; Tue, 14 Jan 2025 05:36:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1875280002; Tue, 14 Jan 2025 00:36:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ACBA2280001; Tue, 14 Jan 2025 00:36:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94451280002; Tue, 14 Jan 2025 00:36:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7412F280001 for ; Tue, 14 Jan 2025 00:36:13 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3018F438C9 for ; Tue, 14 Jan 2025 05:36:13 +0000 (UTC) X-FDA: 83004946626.13.1643B1E Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by imf10.hostedemail.com (Postfix) with ESMTP id E0DD8C0003 for ; Tue, 14 Jan 2025 05:36:10 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=iXWopfu7; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf10.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736832971; a=rsa-sha256; cv=none; b=dTt5UkmTvP119cl/tsw3hJJ2B5884s0FFha9mEkPwTPUzwUc+IJsUhBINCTiXrW6QvZ0s9 GXxTppKj3/cWx8rL43LzZEi6ElYPQgTDdpbS4AS/lNJvT03pliHg/OVctOf4aVm8OQrWRE edkmeOV3z6/Z0uClwcX80j91r998Rf0= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=iXWopfu7; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf10.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736832971; 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:dkim-signature; bh=drhXWUnxNp13ZTiPp3leq5WA8tzUkJEr4CWQ0Yv1pZw=; b=gi4lq0ALo+XvfAy5FrQgAPZAGjzsXRfGWRTaTXb2W9USAkLkvO/IsXVTY4CDFpX3LgriDX Q9vXUJxwvRBtNydwQvMdCAvKSS6otgAW2kK6EcY4/WlFpYg3zpMnvLvHYVksg1gjn4nSNp R57BHnpnqfrewxI5CNfo4l31RNzM2vY= Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50DH3oqq020410; Tue, 14 Jan 2025 05:36:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= drhXWUnxNp13ZTiPp3leq5WA8tzUkJEr4CWQ0Yv1pZw=; b=iXWopfu7nQ9ngkx7 h9V/MplxVwH+7w8ND4lXLO9AoxrObwWm6Rv9F5E1sL5EmPsM5k+9BrZTA29a60rc 4No3GOYTHQc1X4zvMoRu75RlwOXDjgCwnxKCS2q/cMNwKsgdgMz384yv0sCYO/dR oGaop5K6sWKj8cnCleQybJtOqPRZxMpj/PPi1xZeAMP/QUZqfcIoapQ6GlXYNh8V m6cOTT02MFtvDQR1DqIEjklPJtQOC0gPnqbJcghap6FBH09vAJ3KExYiSQnIZsl9 3DHoKQ2l2vjts65JrffTIAFnhTPtgDX7P5T1qnliGRJ9hoCDYRzf830qHzYjaqCR Bl+x9A== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4456wa9fhh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:36:03 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 50E5a28k020523 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:36:02 GMT Received: from la-sh002-lnx.ap.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 13 Jan 2025 21:35:56 -0800 From: "Jiao, Joey" Date: Tue, 14 Jan 2025 13:34:34 +0800 Subject: [PATCH 4/7] kcov: introduce new kcov KCOV_TRACE_UNIQ_CMP mode MIME-Version: 1.0 Message-ID: <20250114-kcov-v1-4-004294b931a2@quicinc.com> References: <20250114-kcov-v1-0-004294b931a2@quicinc.com> In-Reply-To: <20250114-kcov-v1-0-004294b931a2@quicinc.com> To: Dmitry Vyukov , Andrey Konovalov , Jonathan Corbet , Andrew Morton , Dennis Zhou , Tejun Heo , Christoph Lameter , Catalin Marinas , Will Deacon CC: , , , , , , X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1736832942; l=6956; i=quic_jiangenj@quicinc.com; s=20250114; h=from:subject:message-id; bh=87rus4o59M/h6mbCeTYN+uwPYg3Cu8v5VQQt/ES6TT4=; b=dLbyxsjISwicFnHI2UlW7HXO0FqBJGbKRAtWrXffXPrseH1onOKQ7Uil5a0dOqyIK0G9Sonh3 Af14LF0A5HiDGL5/ZS9Y7gv/n6tgLyBJ6vxQua47w0wN4Ujd1sTIXzx X-Developer-Key: i=quic_jiangenj@quicinc.com; a=ed25519; pk=JPzmfEvx11SW1Q1qtMhFcAx46KP1Ui36jcetDgbev28= X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: -qyd1GNp6Gcg_3HTW0CFg-UHDCJbFmyY X-Proofpoint-ORIG-GUID: -qyd1GNp6Gcg_3HTW0CFg-UHDCJbFmyY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 suspectscore=0 adultscore=0 mlxlogscore=734 priorityscore=1501 phishscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501140044 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E0DD8C0003 X-Stat-Signature: jnfu8ghstjnap8awwd1d4d1odczize4n X-Rspam-User: X-HE-Tag: 1736832970-75200 X-HE-Meta: U2FsdGVkX19kuQCtBcGWvl1Ql2alSMKN1FUZnXnshSN+aZDBr3bxoX5vfqDSstD+TzOWbE2iQMGdL4uEdzBJ9D70Pl58EQM117wDuzTMy+OC9fvM+94OQYAIK3RCtapJRkfLezVQCTypHeYOqQ4gmoxRHGSWTp9qU8t2GZTbnQELwJR9b2VoieD7ZW4Ea+4XSLLB67Jtp9h8wq24gFhPStsiR6zQ6n2Xz6mvjBo6N9wSKgBMtcELbONSPO1FeKea7DE+0Pg0Gct5WVNxv7jzkfjCYbBjpOQ9xwyQV6802fzpRsTaVK0Zx4tZason3rYshx/lFhP672PC6Bu7L3ABdXyM1H+vhCNZbiwFRTg2lB5JidPxAPYxrA4Q0eaFMgwba7w4dR9O1tsJPxUJvRqNeYmIIehA/SBJ+BTdw4jHO3oWOAePVDkjOCgyq6GxwQogxJ/rJ5AnZbsTLBoG9hJs50jENF+Cg/IOSmyyz3v92slxgnswTVXQOkdx/9UeclI/VdTZygmurB5vwz4DCcFb9c6nGYCkEXwTyROdi6Dbfu8I1Tvjgd4OxEtztb4mJO7z96pVaEubekzQCb8PBh56eEuarxZ2sBY8b2FXcJtAaTg1Vbpgg3p6ILYBUmyuRxV6YS18UITDt9Akesutb+FfguUFH6dVF5xhQUlR/OpGIT6Zx8/hrmgPEfcfWIKVY6GiHqiNPsOrFYMbAj2E4BsB+NyD2OFs+S5CTgCANsrKmHhc4aygqG+Qt65F6h0EPfhvhDp+erOvKC7JNzauAkMwwrYaIDnTiWEKcdYlJs6qituChCsBmDeLbASpP2LAOr/n1ZP7k3VRAgbpVB64RaUq0XnMxtNaEmtLdowmtNneJtgHYiOYTUbAUVlaZSY6NjDq0y8pMiXEwHjxv4oz5qMkMZtNFmoMr53HET4eyQKzzOkdTkD3nspQIwWkH+q21m4PBH7lItZT75EC5E+Omxj PWGbPr0q 05vPmZg37U1ssQQto9CKfZjOGxSVMne6To/+XNI7Z7aTLcRwHVt+X5mkSPLYxRLwoeGsBrKIpu2AWsEoYq97QN1pdmVuFCvltRL6OaCYFzywCq6bgu97M+v4kgXQ2kC4YTL4lXNvP7XMrrHC0Xscp6v2+ZrdroZaWesE1344st9ZHpsaHXlq8uOLtOXR0h9wda/metgIKkKGPHKxcuCMW2hpEygk6BrzkEVl4ZBdsxlV2dhIry5Zrp2cS47mwlDFdccIH3qq9AvY+hMCS+fMKa9JUlBq8Eu/80XdlgTIlWXgj2QlHrwTYDrCUU0PB6mZu3r74Zjw3GKFzSRw492unGyFLJM2AwhOHhP1CDBtH4hbmSSrMW5Vuu1erTA== 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: List-Subscribe: List-Unsubscribe: Similar to KCOV_TRACE_CMP mode, KCOV_TRACE_UNIQ_CMP stores unique CMP data into area. Signed-off-by: Jiao, Joey --- include/linux/kcov.h | 2 + include/uapi/linux/kcov.h | 2 + kernel/kcov.c | 112 ++++++++++++++++++++++++++++++++-------------- 3 files changed, 83 insertions(+), 33 deletions(-) diff --git a/include/linux/kcov.h b/include/linux/kcov.h index 56b858205ba16c47fc72bda9938c98f034503c8c..a78d78164bf75368c71a958a5438fc3ee68c95ca 100644 --- a/include/linux/kcov.h +++ b/include/linux/kcov.h @@ -27,6 +27,8 @@ enum kcov_mode { KCOV_MODE_TRACE_UNIQ_PC = 16, /* Collecting uniq edge mode. */ KCOV_MODE_TRACE_UNIQ_EDGE = 32, + /* Collecting uniq cmp mode. */ + KCOV_MODE_TRACE_UNIQ_CMP = 64, }; #define KCOV_IN_CTXSW (1 << 30) diff --git a/include/uapi/linux/kcov.h b/include/uapi/linux/kcov.h index 9b2019f0ab8b8cb5426d2d6b74472fa1a7293817..08abfca273c9624dc54a2c70b12a4a9302700f26 100644 --- a/include/uapi/linux/kcov.h +++ b/include/uapi/linux/kcov.h @@ -39,6 +39,8 @@ enum { KCOV_TRACE_UNIQ_PC = 2, /* Collecting uniq edge mode. */ KCOV_TRACE_UNIQ_EDGE = 4, + /* Collecting uniq CMP mode. */ + KCOV_TRACE_UNIQ_CMP = 8, }; /* diff --git a/kernel/kcov.c b/kernel/kcov.c index c04bbec9ac3186a5145240de8ac609ad8a7ca733..af73c40114d23adedab8318e8657d24bf36ae865 100644 --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -36,6 +36,11 @@ struct kcov_entry { unsigned long ent; +#ifdef CONFIG_KCOV_ENABLE_COMPARISONS + unsigned long type; + unsigned long arg1; + unsigned long arg2; +#endif struct hlist_node node; }; @@ -44,7 +49,7 @@ struct kcov_entry { #define MIN_POOL_ALLOC_ORDER ilog2(roundup_pow_of_two(sizeof(struct kcov_entry))) /* - * kcov hashmap to store uniq pc, prealloced mem for kcov_entry + * kcov hashmap to store uniq pc|edge|cmp, prealloced mem for kcov_entry * and area shared between kernel and userspace. */ struct kcov_map { @@ -87,7 +92,7 @@ struct kcov { unsigned long prev_pc; /* Coverage buffer shared with user space. */ void *area; - /* Coverage hashmap for unique pc. */ + /* Coverage hashmap for unique pc|cmp. */ struct kcov_map *map; /* Edge hashmap for unique edge. */ struct kcov_map *map_edge; @@ -289,14 +294,23 @@ static notrace inline void kcov_map_add(struct kcov_map *map, struct kcov_entry struct kcov *kcov; struct kcov_entry *entry; unsigned int key = hash_key(ent); - unsigned long pos, *area; + unsigned long pos, start_index, end_pos, max_pos, *area; kcov = t->kcov; - hash_for_each_possible_rcu(map->buckets, entry, node, key) { - if (entry->ent == ent->ent) - return; - } + if ((mode == KCOV_MODE_TRACE_UNIQ_PC || + mode == KCOV_MODE_TRACE_UNIQ_EDGE)) + hash_for_each_possible_rcu(map->buckets, entry, node, key) { + if (entry->ent == ent->ent) + return; + } + else + hash_for_each_possible_rcu(map->buckets, entry, node, key) { + if (entry->ent == ent->ent && entry->type == ent->type && + entry->arg1 == ent->arg1 && entry->arg2 == ent->arg2) { + return; + } + } entry = (struct kcov_entry *)gen_pool_alloc(map->pool, 1 << MIN_POOL_ALLOC_ORDER); if (unlikely(!entry)) @@ -306,16 +320,31 @@ static notrace inline void kcov_map_add(struct kcov_map *map, struct kcov_entry memcpy(entry, ent, sizeof(*entry)); hash_add_rcu(map->buckets, &entry->node, key); - if (mode == KCOV_MODE_TRACE_UNIQ_PC) + if (mode == KCOV_MODE_TRACE_UNIQ_PC || mode == KCOV_MODE_TRACE_UNIQ_CMP) area = t->kcov_area; else area = kcov->map_edge->area; pos = READ_ONCE(area[0]) + 1; - if (likely(pos < t->kcov_size)) { - WRITE_ONCE(area[0], pos); - barrier(); - area[pos] = ent->ent; + if (mode == KCOV_MODE_TRACE_UNIQ_PC || mode == KCOV_MODE_TRACE_UNIQ_EDGE) { + if (likely(pos < t->kcov_size)) { + WRITE_ONCE(area[0], pos); + barrier(); + area[pos] = ent->ent; + } + } else { + start_index = 1 + (pos - 1) * KCOV_WORDS_PER_CMP; + max_pos = t->kcov_size * sizeof(unsigned long); + end_pos = (start_index + KCOV_WORDS_PER_CMP) * sizeof(u64); + if (likely(end_pos <= max_pos)) { + /* See comment in __sanitizer_cov_trace_pc(). */ + WRITE_ONCE(area[0], pos); + barrier(); + area[start_index] = ent->type; + area[start_index + 1] = ent->arg1; + area[start_index + 2] = ent->arg2; + area[start_index + 3] = ent->ent; + } } } @@ -384,33 +413,44 @@ static void notrace write_comp_data(u64 type, u64 arg1, u64 arg2, u64 ip) struct task_struct *t; u64 *area; u64 count, start_index, end_pos, max_pos; + struct kcov_entry entry = {0}; + unsigned int mode; t = current; - if (!check_kcov_mode(KCOV_MODE_TRACE_CMP, t)) + if (!check_kcov_mode(KCOV_MODE_TRACE_CMP | KCOV_MODE_TRACE_UNIQ_CMP, t)) return; + mode = t->kcov_mode; ip = canonicalize_ip(ip); - /* - * We write all comparison arguments and types as u64. - * The buffer was allocated for t->kcov_size unsigned longs. - */ - area = (u64 *)t->kcov_area; - max_pos = t->kcov_size * sizeof(unsigned long); - - count = READ_ONCE(area[0]); - - /* Every record is KCOV_WORDS_PER_CMP 64-bit words. */ - start_index = 1 + count * KCOV_WORDS_PER_CMP; - end_pos = (start_index + KCOV_WORDS_PER_CMP) * sizeof(u64); - if (likely(end_pos <= max_pos)) { - /* See comment in __sanitizer_cov_trace_pc(). */ - WRITE_ONCE(area[0], count + 1); - barrier(); - area[start_index] = type; - area[start_index + 1] = arg1; - area[start_index + 2] = arg2; - area[start_index + 3] = ip; + if (mode == KCOV_MODE_TRACE_CMP) { + /* + * We write all comparison arguments and types as u64. + * The buffer was allocated for t->kcov_size unsigned longs. + */ + area = (u64 *)t->kcov_area; + max_pos = t->kcov_size * sizeof(unsigned long); + + count = READ_ONCE(area[0]); + + /* Every record is KCOV_WORDS_PER_CMP 64-bit words. */ + start_index = 1 + count * KCOV_WORDS_PER_CMP; + end_pos = (start_index + KCOV_WORDS_PER_CMP) * sizeof(u64); + if (likely(end_pos <= max_pos)) { + /* See comment in __sanitizer_cov_trace_pc(). */ + WRITE_ONCE(area[0], count + 1); + barrier(); + area[start_index] = type; + area[start_index + 1] = arg1; + area[start_index + 2] = arg2; + area[start_index + 3] = ip; + } + } else { + entry.type = type; + entry.arg1 = arg1; + entry.arg2 = arg2; + entry.ent = ip; + kcov_map_add(t->kcov->map, &entry, t, KCOV_MODE_TRACE_UNIQ_CMP); } } @@ -730,6 +770,12 @@ static int kcov_get_mode(unsigned long arg) mode |= KCOV_MODE_TRACE_UNIQ_PC; if (arg & KCOV_TRACE_UNIQ_EDGE) mode |= KCOV_MODE_TRACE_UNIQ_EDGE; + if (arg == KCOV_TRACE_UNIQ_CMP) +#ifdef CONFIG_KCOV_ENABLE_COMPARISONS + mode = KCOV_MODE_TRACE_UNIQ_CMP; +#else + return -EOPNOTSUPP; +#endif if (!mode) return -EINVAL; From patchwork Tue Jan 14 05:34:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Jiao X-Patchwork-Id: 13938434 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 0376AC02183 for ; Tue, 14 Jan 2025 05:36:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A86C280003; Tue, 14 Jan 2025 00:36:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 856CC280001; Tue, 14 Jan 2025 00:36:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A993280003; Tue, 14 Jan 2025 00:36:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4BDAE280001 for ; Tue, 14 Jan 2025 00:36:18 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 192BFAEDA8 for ; Tue, 14 Jan 2025 05:36:18 +0000 (UTC) X-FDA: 83004946836.02.81D87BD Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf04.hostedemail.com (Postfix) with ESMTP id B8F1140011 for ; Tue, 14 Jan 2025 05:36:15 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=JCcY18Jy; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf04.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736832975; 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:dkim-signature; bh=SnTIiCvc99mwVePAnY7xDBhzjlSnYyKXixXlpKzOnM4=; b=mrcMjp1aMsot8JwbF8H/zrcQPH/ePm/evBz7lxW5FaQqTCpoRtNZ7jriEA6XGrPlMCV0CE 4zM3FDT43ZYwWe3TwkzFPzl/UFKzIyXEWEGWyxddJRlVG/3LKghGUA4CrmnYm0GCMum+Xg uHFQSlHvumINijIvPzXxh9fxyG90OPo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736832975; a=rsa-sha256; cv=none; b=r9AYsyIX8WtRXTEKD0vwEM4Twttx4isxN2M7exPRlcq0/OgJG4b3pRZM00GwHYCKTyAMky yN5Fyw7aMkO5DxLQplRHpokMrjY4oHc4WZmdSppA9+H1JnbE2GfQ3WmDQ7aJm9edzgvLHb yyHCY4dUEf41lDJN4awwdPi56U0s9wA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=JCcY18Jy; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf04.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50E23rPd008664; Tue, 14 Jan 2025 05:36:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= SnTIiCvc99mwVePAnY7xDBhzjlSnYyKXixXlpKzOnM4=; b=JCcY18JyP35QhE2i nTjLZc54+6+TZtbHeqOYLvTzs51/WglbUjzKvSN3lsVfQz+xcPJwbZ99TgdvzWn7 LXMehmLWqLiUyLd4SPi0JjnNHo2mo15MwWRqxvyHDbA9BfK+Hr/9CV2YcB9CJ8oW D9iSo3GMZWa0RQfAoewUcgVxfAF0ofbldSUuN/t1rRoSVGgmjZO2MU5La2FXQemL fWgQqX6qZ79MfriW7E0xk2uwE2Gbku+0Sm4DgW20S7AdSBXti4neB5cW/rvT+y84 739faLja8SC7lzZzbseLpoMcCZmkxjWf0zEbIuuq1tvq8HD+iroq0bUWawsQ24pl HEv1UQ== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 445eterdbu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:36:06 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 50E5a5VP031710 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:36:05 GMT Received: from la-sh002-lnx.ap.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 13 Jan 2025 21:35:59 -0800 From: "Jiao, Joey" Date: Tue, 14 Jan 2025 13:34:35 +0800 Subject: [PATCH 5/7] kcov: add the new KCOV uniq modes example code MIME-Version: 1.0 Message-ID: <20250114-kcov-v1-5-004294b931a2@quicinc.com> References: <20250114-kcov-v1-0-004294b931a2@quicinc.com> In-Reply-To: <20250114-kcov-v1-0-004294b931a2@quicinc.com> To: Dmitry Vyukov , Andrey Konovalov , Jonathan Corbet , Andrew Morton , Dennis Zhou , Tejun Heo , Christoph Lameter , Catalin Marinas , Will Deacon CC: , , , , , , X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1736832942; l=11230; i=quic_jiangenj@quicinc.com; s=20250114; h=from:subject:message-id; bh=Lulb9I7d15ITpgpA7vYK556BzHyWX5kLFMs7zHurtPk=; b=PsYnlyeqPpQvbH0Tjx/23z40jyNSYl78V1dqIGIKdCPIfjW6tQcTCFyzJ9UvXBOuXjtWtUwDB TAqwKIXfgCUBSNrKOSChk4WtD7SAjYOBbZ/LvHcIKI1yVt1GRWOuj8H X-Developer-Key: i=quic_jiangenj@quicinc.com; a=ed25519; pk=JPzmfEvx11SW1Q1qtMhFcAx46KP1Ui36jcetDgbev28= X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: wnv8w4hud187Ydr9CX1bF6ILuw6Aa77S X-Proofpoint-GUID: wnv8w4hud187Ydr9CX1bF6ILuw6Aa77S X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 impostorscore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501140044 X-Stat-Signature: s44nr4skd5zytzkdbzz7giajyh5qsben X-Rspamd-Queue-Id: B8F1140011 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1736832975-47453 X-HE-Meta: U2FsdGVkX18Nr5ygCnakjRmM4E45S/7mtDQftiL+9PogMiDj8a1E8fLBg79B58bBFOvj4jlIfYvKjVXv6phJx0X2gtAltlH3vnFdF0alSSA1hOBWBtlmm05L4tGLIOSZD9hOm/b8GWSveXfvkpUi5mVQHN/xYP8NK/CiAPdLX/0UzResGD/GwdAo/cQ4HyU+z8AGbGRLgwXqZjcrrq+4wLZds4Q0qjdKwYOjgqpQdpd7L4xT5BRtZPzqwOpyqZV9O94LiCVzKtAekbpaycke3JaSeN2oA0IOpK8M8pRRQ9O8kU5TIfyVsW8J2KUAvgcA07Hh/qEuaNMK7YyRb+Rd5l2dqV7GHTRq9WY16zKr4stn/elcnM+jAbP8YQv3jdQaDHqhRXxttse+Gp4iueHX5D+trpsQn0hR6FDUW0IHr5Z3e0wvO67DBDlsaePmH0KnsRCX82spH8qVCJUSMcQadM8P0+YX3Qg5pMp+AkIAQvxHC3cl5+LxMIKl2dbMF96TldSSVMYjmEQOdKQsp1bgA93n123D0zWkKzXvLeeV61DVt3QmaYX+2ncrMa8D8qzv/6g7ITOQ7AzH0gasqfsH4Z27WY8Oex+JtxlrHrQEh2bpmgVf4/zq+yz8tRezHDKEKkRih78lt3U8hqCieTUNgCNdc8t+3DsklueHTpES/QtmjJ77Un5Opbes2BwfOjtWoFQH7F7s7nXWJ0LkoUVJELKf11nHWXZeIS7S3puU1dsf3OTIlg6TqlZMFWXGjKkFZysHqGikQMvh1Z1eL8FA3S/XKgIaA/pbJjrE5YOgxltYRcJWBuR1p0lwNRFV+Q3hesLRtQuQWbb3METK9Azb27OnW39Uu0RtgN4oEPJyLx8NJnq73zktYArAzNva0mJxZTbQdFRhjQz13/N0GlB4otbzQntCT4jFpnGjQ056JKaeggzTAQKBo3pH8ZxCmYEROl+OQC5YDNz4Q09T/Pj ztOWMnN2 itKWrq8CW3aXZZGbbflDf2gWu3RkYoTdNjjnEXPqNR83lTx8JTY9vS0jMGY3moPBgjdPDjsEbV3P2ptB5WBAkkpUfahmz6Qwp8WQsXepULmmNnK0HCra3BsFMcDf8si1adskvyVhgY7u4rz60KoC58znoKlNcns4v7qQ4dQS7IVCFGamff85zXcXXTa5cjsr8PEF+wghZjQ1PrcliAWyFhzcXG/aOd5LERNKnuTdHgFfREoqn5wAKKk5xh7ea4leLqQCYHXMmblYfIYInCbWO3+eLkJ2o5l8bGg5JAkYB0iKXahdTddCu2dLcWtOgV9bHCKZqrFJ4txqE9Qk= 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: List-Subscribe: List-Unsubscribe: - Use single program to select different mode. - Mode [0|1|2|4|8] to KCOV_TRACE_[PC|CMP|UNIQ_PC|UNIQ_EDGE|UNIQ_CMP]. - Mode 6 to KCOV_TRACE_UNIQ_PC and KCOV_TRACE_UNIQ_EDGE. Signed-off-by: Jiao, Joey --- Documentation/dev-tools/kcov.rst | 243 ++++++++++++++++++++------------------- 1 file changed, 122 insertions(+), 121 deletions(-) diff --git a/Documentation/dev-tools/kcov.rst b/Documentation/dev-tools/kcov.rst index 6611434e2dd247c6c40afcbf1e6c4e22e0562176..061ae20b867fd9e68b447b86719733278ee6b86f 100644 --- a/Documentation/dev-tools/kcov.rst +++ b/Documentation/dev-tools/kcov.rst @@ -40,11 +40,12 @@ Coverage data only becomes accessible once debugfs has been mounted:: mount -t debugfs none /sys/kernel/debug -Coverage collection +Coverage collection for different modes ------------------- The following program demonstrates how to use KCOV to collect coverage for a -single syscall from within a test program: +single syscall from within a test program, argv[1] can be provided to select +which mode to enable: .. code-block:: c @@ -60,55 +61,130 @@ single syscall from within a test program: #include #include - #define KCOV_INIT_TRACE _IOR('c', 1, unsigned long) + #define KCOV_INIT_TRACE _IOR('c', 1, unsigned long) #define KCOV_ENABLE _IO('c', 100) - #define KCOV_DISABLE _IO('c', 101) + #define KCOV_DISABLE _IO('c', 101) #define COVER_SIZE (64<<10) #define KCOV_TRACE_PC 0 #define KCOV_TRACE_CMP 1 + #define KCOV_TRACE_UNIQ_PC 2 + #define KCOV_TRACE_UNIQ_EDGE 4 + #define KCOV_TRACE_UNIQ_CMP 8 + + /* Number of 64-bit words per record. */ + #define KCOV_WORDS_PER_CMP 4 + + /* + * The format for the types of collected comparisons. + * + * Bit 0 shows whether one of the arguments is a compile-time constant. + * Bits 1 & 2 contain log2 of the argument size, up to 8 bytes. + */ + + #define KCOV_CMP_CONST (1 << 0) + #define KCOV_CMP_SIZE(n) ((n) << 1) + #define KCOV_CMP_MASK KCOV_CMP_SIZE(3) int main(int argc, char **argv) { - int fd; - unsigned long *cover, n, i; - - /* A single fd descriptor allows coverage collection on a single - * thread. - */ - fd = open("/sys/kernel/debug/kcov", O_RDWR); - if (fd == -1) - perror("open"), exit(1); - /* Setup trace mode and trace size. */ - if (ioctl(fd, KCOV_INIT_TRACE, COVER_SIZE)) - perror("ioctl"), exit(1); - /* Mmap buffer shared between kernel- and user-space. */ - cover = (unsigned long*)mmap(NULL, COVER_SIZE * sizeof(unsigned long), - PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if ((void*)cover == MAP_FAILED) - perror("mmap"), exit(1); - /* Enable coverage collection on the current thread. */ - if (ioctl(fd, KCOV_ENABLE, KCOV_TRACE_PC)) - perror("ioctl"), exit(1); - /* Reset coverage from the tail of the ioctl() call. */ - __atomic_store_n(&cover[0], 0, __ATOMIC_RELAXED); - /* Call the target syscall call. */ - read(-1, NULL, 0); - /* Read number of PCs collected. */ - n = __atomic_load_n(&cover[0], __ATOMIC_RELAXED); - for (i = 0; i < n; i++) - printf("0x%lx\n", cover[i + 1]); - /* Disable coverage collection for the current thread. After this call - * coverage can be enabled for a different thread. - */ - if (ioctl(fd, KCOV_DISABLE, 0)) - perror("ioctl"), exit(1); - /* Free resources. */ - if (munmap(cover, COVER_SIZE * sizeof(unsigned long))) - perror("munmap"), exit(1); - if (close(fd)) - perror("close"), exit(1); - return 0; + int fd; + unsigned long *cover, *edge, n, n1, i, type, arg1, arg2, is_const, size; + unsigned int mode = KCOV_TRACE_PC; + + /* argv[1] controls which mode to use, default to KCOV_TRACE_PC. + * supported modes include: + * KCOV_TRACE_PC + * KCOV_TRACE_CMP + * KCOV_TRACE_UNIQ_PC + * KCOV_TRACE_UNIQ_EDGE + * KCOV_TRACE_UNIQ_PC | KCOV_TRACE_UNIQ_EDGE + * KCOV_TRACE_UNIQ_CMP + */ + if (argc > 1) + mode = (unsigned int)strtoul(argv[1], NULL, 10); + printf("The mode is: %u\n", mode); + if (mode != KCOV_TRACE_PC && mode != KCOV_TRACE_CMP && + !(mode & (KCOV_TRACE_UNIQ_PC | KCOV_TRACE_UNIQ_EDGE | KCOV_TRACE_UNIQ_CMP))) { + printf("Unsupported mode!\n"); + exit(1); + } + /* A single fd descriptor allows coverage collection on a single + * thread. + */ + fd = open("/sys/kernel/debug/kcov", O_RDWR); + if (fd == -1) + perror("open"), exit(1); + /* Setup trace mode and trace size. */ + if (ioctl(fd, KCOV_INIT_TRACE, COVER_SIZE)) + perror("ioctl"), exit(1); + /* Mmap buffer shared between kernel- and user-space. */ + cover = (unsigned long*)mmap(NULL, COVER_SIZE * sizeof(unsigned long), + PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if ((void*)cover == MAP_FAILED) + perror("mmap"), exit(1); + if (mode & KCOV_TRACE_UNIQ_EDGE) { + edge = (unsigned long*)mmap(NULL, COVER_SIZE * sizeof(unsigned long), + PROT_READ | PROT_WRITE, MAP_SHARED, fd, COVER_SIZE * sizeof(unsigned long)); + if ((void*)edge == MAP_FAILED) + perror("mmap"), exit(1); + } + /* Enable coverage collection on the current thread. */ + if (ioctl(fd, KCOV_ENABLE, mode)) + perror("ioctl"), exit(1); + /* Reset coverage from the tail of the ioctl() call. */ + __atomic_store_n(&cover[0], 0, __ATOMIC_RELAXED); + if (mode & KCOV_TRACE_UNIQ_EDGE) + __atomic_store_n(&edge[0], 0, __ATOMIC_RELAXED); + /* Call the target syscall call. */ + read(-1, NULL, 0); + /* Read number of PCs collected. */ + n = __atomic_load_n(&cover[0], __ATOMIC_RELAXED); + if (mode & KCOV_TRACE_UNIQ_EDGE) + n1 = __atomic_load_n(&edge[0], __ATOMIC_RELAXED); + if (mode & (KCOV_TRACE_CMP | KCOV_TRACE_UNIQ_CMP)) { + for (i = 0; i < n; i++) { + uint64_t ip; + + type = cover[i * KCOV_WORDS_PER_CMP + 1]; + /* arg1 and arg2 - operands of the comparison. */ + arg1 = cover[i * KCOV_WORDS_PER_CMP + 2]; + arg2 = cover[i * KCOV_WORDS_PER_CMP + 3]; + /* ip - caller address. */ + ip = cover[i * KCOV_WORDS_PER_CMP + 4]; + /* size of the operands. */ + size = 1 << ((type & KCOV_CMP_MASK) >> 1); + /* is_const - true if either operand is a compile-time constant.*/ + is_const = type & KCOV_CMP_CONST; + printf("ip: 0x%lx type: 0x%lx, arg1: 0x%lx, arg2: 0x%lx, " + "size: %lu, %s\n", + ip, type, arg1, arg2, size, + is_const ? "const" : "non-const"); + } + } else { + for (i = 0; i < n; i++) + printf("0x%lx\n", cover[i + 1]); + if (mode & KCOV_TRACE_UNIQ_EDGE) { + printf("======edge======\n"); + for (i = 0; i < n1; i++) + printf("0x%lx\n", edge[i + 1]); + } + } + /* Disable coverage collection for the current thread. After this call + * coverage can be enabled for a different thread. + */ + if (ioctl(fd, KCOV_DISABLE, 0)) + perror("ioctl"), exit(1); + /* Free resources. */ + if (munmap(cover, COVER_SIZE * sizeof(unsigned long))) + perror("munmap"), exit(1); + if (mode & KCOV_TRACE_UNIQ_EDGE) { + if (munmap(edge, COVER_SIZE * sizeof(unsigned long))) + perror("munmap"), exit(1); + } + if (close(fd)) + perror("close"), exit(1); + return 0; } After piping through ``addr2line`` the output of the program looks as follows:: @@ -137,85 +213,10 @@ mmaps coverage buffer, and then forks child processes in a loop. The child processes only need to enable coverage (it gets disabled automatically when a thread exits). -Comparison operands collection ------------------------------- - -Comparison operands collection is similar to coverage collection: - -.. code-block:: c - - /* Same includes and defines as above. */ - - /* Number of 64-bit words per record. */ - #define KCOV_WORDS_PER_CMP 4 - - /* - * The format for the types of collected comparisons. - * - * Bit 0 shows whether one of the arguments is a compile-time constant. - * Bits 1 & 2 contain log2 of the argument size, up to 8 bytes. - */ - - #define KCOV_CMP_CONST (1 << 0) - #define KCOV_CMP_SIZE(n) ((n) << 1) - #define KCOV_CMP_MASK KCOV_CMP_SIZE(3) - - int main(int argc, char **argv) - { - int fd; - uint64_t *cover, type, arg1, arg2, is_const, size; - unsigned long n, i; - - fd = open("/sys/kernel/debug/kcov", O_RDWR); - if (fd == -1) - perror("open"), exit(1); - if (ioctl(fd, KCOV_INIT_TRACE, COVER_SIZE)) - perror("ioctl"), exit(1); - /* - * Note that the buffer pointer is of type uint64_t*, because all - * the comparison operands are promoted to uint64_t. - */ - cover = (uint64_t *)mmap(NULL, COVER_SIZE * sizeof(unsigned long), - PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if ((void*)cover == MAP_FAILED) - perror("mmap"), exit(1); - /* Note KCOV_TRACE_CMP instead of KCOV_TRACE_PC. */ - if (ioctl(fd, KCOV_ENABLE, KCOV_TRACE_CMP)) - perror("ioctl"), exit(1); - __atomic_store_n(&cover[0], 0, __ATOMIC_RELAXED); - read(-1, NULL, 0); - /* Read number of comparisons collected. */ - n = __atomic_load_n(&cover[0], __ATOMIC_RELAXED); - for (i = 0; i < n; i++) { - uint64_t ip; - - type = cover[i * KCOV_WORDS_PER_CMP + 1]; - /* arg1 and arg2 - operands of the comparison. */ - arg1 = cover[i * KCOV_WORDS_PER_CMP + 2]; - arg2 = cover[i * KCOV_WORDS_PER_CMP + 3]; - /* ip - caller address. */ - ip = cover[i * KCOV_WORDS_PER_CMP + 4]; - /* size of the operands. */ - size = 1 << ((type & KCOV_CMP_MASK) >> 1); - /* is_const - true if either operand is a compile-time constant.*/ - is_const = type & KCOV_CMP_CONST; - printf("ip: 0x%lx type: 0x%lx, arg1: 0x%lx, arg2: 0x%lx, " - "size: %lu, %s\n", - ip, type, arg1, arg2, size, - is_const ? "const" : "non-const"); - } - if (ioctl(fd, KCOV_DISABLE, 0)) - perror("ioctl"), exit(1); - /* Free resources. */ - if (munmap(cover, COVER_SIZE * sizeof(unsigned long))) - perror("munmap"), exit(1); - if (close(fd)) - perror("close"), exit(1); - return 0; - } - Note that the KCOV modes (collection of code coverage or comparison operands) -are mutually exclusive. +are mutually exclusive, KCOV_TRACE_UNIQ_PC and KCOV_TRACE_UNIQ_EDGE can be +enabled together. + Remote coverage collection -------------------------- From patchwork Tue Jan 14 05:34:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Jiao X-Patchwork-Id: 13938435 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 86F37E77188 for ; Tue, 14 Jan 2025 05:36:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F0D1280004; Tue, 14 Jan 2025 00:36:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A114280001; Tue, 14 Jan 2025 00:36:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0411A280004; Tue, 14 Jan 2025 00:36:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DB513280001 for ; Tue, 14 Jan 2025 00:36:22 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5A2828062B for ; Tue, 14 Jan 2025 05:36:22 +0000 (UTC) X-FDA: 83004947004.28.803D319 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf23.hostedemail.com (Postfix) with ESMTP id EC60B140009 for ; Tue, 14 Jan 2025 05:36:19 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=pib3eWcG; spf=pass (imf23.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736832980; 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:dkim-signature; bh=sbZl6GtDotLNfy1i0ybFvuNDyQMsou97Y3PruXQtvYc=; b=WptuXeqOE6vnSBuOxFdC3uzEzkxoy4QkUQUHAeOt1NsaS6nOvKDyCJxnyXYePxF2mr0knQ CIQbst6Q/v+xfr6kJ2BqtoKLB2bvDGIVCWr4R+4OOwuYUFSMqTTxKHZ5bCKlpu/88o7TU+ 9wzMFwnvUvsSZIISZW0WIEqflBjTktU= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=pib3eWcG; spf=pass (imf23.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736832980; a=rsa-sha256; cv=none; b=VNcWIUOImifYwj9PNv39BQsa0aT8de7xMMLEAExk2vOrsKdrvG5U4sjMAIQEIY8SmA0FbR Qqw5PVXdktJvhT2mm+hVghj6nYZEkFntQqzIa6I4qO7eNbjvzFcVgyrl2QaZv3kc2ye809 n7Uj2oBd6CvX/rIRmwBEK3Y69LMPic8= Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50E40k6j020873; Tue, 14 Jan 2025 05:36:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= sbZl6GtDotLNfy1i0ybFvuNDyQMsou97Y3PruXQtvYc=; b=pib3eWcGHBy1q5JO eqjOf146/5gOab2zbejzkS2zfNrQW2mDtMyDQAhbTP8n6nM/nD+Fm8FIRFxSv/hw PLyXf92MGH3p2QrEOwHZ6bW4YJ5bXwPBnoJValvoWFGYWzgcj/X2gtl2h7iBE+Vd Ud3nCD2wZycQ/XRcxOh4udyfp965MOGdXQDIT855hgCMhLfW9+XnleDiTW2QSIB4 X87O1VDwqdCOSIV5lQRK7vXnwtIAGY6aUU8y2LGTB+70/wXMtS3h3aUhQ5LO7jvG 4syLPlEWs1ra4stuiLFpyJfP6FDVN09pNxgY7lcUnDKkKAZbJ2L8nYFv1UwTtxj+ NhOR9Q== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 445gh60522-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:36:09 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 50E5a9Sk032192 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:36:09 GMT Received: from la-sh002-lnx.ap.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 13 Jan 2025 21:36:03 -0800 From: "Jiao, Joey" Date: Tue, 14 Jan 2025 13:34:36 +0800 Subject: [PATCH 6/7] kcov: disable instrumentation for genalloc and bitmap MIME-Version: 1.0 Message-ID: <20250114-kcov-v1-6-004294b931a2@quicinc.com> References: <20250114-kcov-v1-0-004294b931a2@quicinc.com> In-Reply-To: <20250114-kcov-v1-0-004294b931a2@quicinc.com> To: Dmitry Vyukov , Andrey Konovalov , Jonathan Corbet , Andrew Morton , Dennis Zhou , Tejun Heo , Christoph Lameter , Catalin Marinas , Will Deacon CC: , , , , , , X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1736832942; l=875; i=quic_jiangenj@quicinc.com; s=20250114; h=from:subject:message-id; bh=EXcTVhs0X6v2Sn7y/hEncpAKcEG0rAcAKxXrOMGyy08=; b=DPbLlmPLNl9LVZSN1bfAVqQsyLNyv2HqNKFt/s+LvYi8cIICAf3fRzFkJUf2iumIUN1xDcknK z8FbRLfWBReCSA8dPFnjOChSeV9/ToF4C7tcNQG1a9YzeqfEVSpKKbd X-Developer-Key: i=quic_jiangenj@quicinc.com; a=ed25519; pk=JPzmfEvx11SW1Q1qtMhFcAx46KP1Ui36jcetDgbev28= X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: CzmwwnNWwZyaCVN5LYXu9a4ccWBCgyOh X-Proofpoint-GUID: CzmwwnNWwZyaCVN5LYXu9a4ccWBCgyOh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 suspectscore=0 malwarescore=0 mlxlogscore=778 phishscore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501140044 X-Rspamd-Server: rspam05 X-Stat-Signature: 8y881usxnf1zitimmzx5oregubeisiu9 X-Rspamd-Queue-Id: EC60B140009 X-Rspam-User: X-HE-Tag: 1736832979-418259 X-HE-Meta: U2FsdGVkX1+mfihdrmpySyf0QkOgDqMP/qMGJKLuT9mlJECBgWFe+b5OWDCN7fdxSp1jivluwnY4PX4WH2/OZWmJiZnaCsOOSfLyIo+iKM+ZkbXQfTI3wo5hEer+iSxDBxaBhyz4Ty6GZ6T9yr19RNICDSFLr4i1A32fmOKGmjPVHv15S6qWR8PHyl1IqreAphLQghDTrZdjSPO7SKRFVi06cABBhfLacZbGhvbEnbgntbV8Yk5wT+H0EEFoJuvZjwjej5LiFzfwhC6s0ZbzXmYPSvlauDT7JhK/ajG1wE00SdnXgq7MHvdc7Tb6QbEeZvWKdBvbvh9ZAJMb3cJV9rQParHDEQYi3dnzqRtmtFhQs9o+/FHPJw3aVthJ8nawikacil4u2xkPsxrC/QCFYRvzW3V0Jl7MsHuYlvWUH40+LeJzswrBa0fYnaYK8ICeWPf/xJB53Dnh00yOa2BvCjuy1ZeHz3tBgM//RHmrR4g70HKXE+HOG8IjWk+Hf7UE6Z7kRlPfcN6zH9m+D6/Z88GUeDc3kKI1hNueGtmOAVCcaEuG1C1Cv5NgYnivlJ/qExNVbCAon4du3+iLWDRhZ1O5LIggBJ18rORG09cDgoi638VPbU+yPSzFtZGnVDMg+BI189cz4eDPlYCVMsVrfz873ZTMYeeEMcxs2CG41wLMUOiRfzBJ1SIxw7EuMyCrpeSCTUbbr68dyG3JNq4R4fM07esgg3bhdxz7qghdZnF+VfXvFHYOLlwS2bKbFnGKyfUZQ9iU90l3vRsdJQlGWEXVtjHlqynlRvPqR74XbEbi1nFcIwVaaIlkx7l7J5EepqVYf0o8Z3PgRSqFi6nGfS1g3lnusVByljS7JBagEu0vFeLYG6/g/3SDW/JOgjirpDJetqkxZc70pBB53htF1p2GopwQbpolzgH39OwAFzpJlaWUQbf76lEWRvQ2qZPbX0C7WxDbVflprnxx+kJ cNHHQ/bX sd/52NK1lp7mEyeEWAqAxyjCWzBEVfcCdHHaoWHzt2VTWJqKxfbhvzqNqtp6sn0MPQo8vw9T2WgnQYdcPoxrIkqiAC//8n/5OZOjf7w7+kUldiJWka2BQU5bg1OeHtVuPN4eyGtoL1CRhDJu21R0I7NuUgvmO8NbAYm28hhXVcayFkrYA74mjUqNWResU1QzD8LrstCJZmXDRa9E+LuQAi/UD0YZ5nH9cbtHQT95aLwh6CT6pXXubUdDPCMUVoFlhzBE/5MfCsNR1pL3rw7bvDzHPfQRkvv6lTEZBi2TFruWm3m7Fwk5g2nowUBsZCIHkzI5t/ksdwMYOtkYD/ElMcJmEttGSZLgwm6x8gAhcB980Xup7mWembQlUgrMRG624Gz7B 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: List-Subscribe: List-Unsubscribe: gen_pool_alloc in kcov_map_add triggers recursive call, which trigger BUG: TASK stack guard page was hit at ffffc9000451ff38. Disable KCOV to avoid the recursive call. Signed-off-by: Jiao, Joey --- lib/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Makefile b/lib/Makefile index a8155c972f02856fcc61ee949ddda436cfe211ff..7a110a9a4a527b881ca3a0239d0b60511cb6e38b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -15,6 +15,8 @@ KCOV_INSTRUMENT_debugobjects.o := n KCOV_INSTRUMENT_dynamic_debug.o := n KCOV_INSTRUMENT_fault-inject.o := n KCOV_INSTRUMENT_find_bit.o := n +KCOV_INSTRUMENT_genalloc.o := n +KCOV_INSTRUMENT_bitmap.o := n # string.o implements standard library functions like memset/memcpy etc. # Use -ffreestanding to ensure that the compiler does not try to "optimize" From patchwork Tue Jan 14 05:34:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Jiao X-Patchwork-Id: 13938436 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 7E790C02184 for ; Tue, 14 Jan 2025 05:36:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB5A6280005; Tue, 14 Jan 2025 00:36:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D3A59280001; Tue, 14 Jan 2025 00:36:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B170F280005; Tue, 14 Jan 2025 00:36:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8EE5B280001 for ; Tue, 14 Jan 2025 00:36:24 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2ED7D806A2 for ; Tue, 14 Jan 2025 05:36:24 +0000 (UTC) X-FDA: 83004947088.10.6690516 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf21.hostedemail.com (Postfix) with ESMTP id B62BC1C0008 for ; Tue, 14 Jan 2025 05:36:21 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=HikSzvI7; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf21.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736832981; 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:dkim-signature; bh=/Ra3dSoqbIv2eF9zoZUbyQQPjXpOzfwJvCpeTMxHEKs=; b=xULz7hKbfi0ySdI30kNeSGHHH7/ApBugG2sqIEcMkfhojQejwcPgpyQuHy/iPnWpI7vCQN j1+fs90SCz4R1bQdIQJ7WLSS0lMPhOVKHcuFl9XaUHp4FnwvoHvNMXiB7fSZe9KeTqrZ5H 6d3Ep0dQI6wXV9WpKUpMY/3gR95Q4IE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736832981; a=rsa-sha256; cv=none; b=AYRvt1tyb+tQITv77GllPRol6vTndCsVLaRMCBNBhJNdNYC1G9F1DtgFD6sng5xiAGBHlG vhkt+Ewb3Lwhb1OVd4YexxxXDgufIcV1MJqsTukdLTkvZzuJU/GaBkqfrvKvS9bgi00ucU RN/ykS9p3Q3u2bxKWmjiOOSpknsdfJ4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=HikSzvI7; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf21.hostedemail.com: domain of quic_jiangenj@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_jiangenj@quicinc.com Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50E40bZB020725; Tue, 14 Jan 2025 05:36:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= /Ra3dSoqbIv2eF9zoZUbyQQPjXpOzfwJvCpeTMxHEKs=; b=HikSzvI7KYxlMco7 RYWzAkybYaofzND7NE4hK4kh74cceDeIxcHy4IlcELeV+V1szgEwQftpeoMU4ZxX I5vZm1eC4knIGqbT81HKE+xnKB7NP/T/S7DL4FTYVVSQLQp6k8hlGJ0JB6OvTIIV ogtxPXvzkGPqKoc7DrYPk8ot36bUWdSE1GZRtMUo5ZGxUkfriEokjDsR+THoxPFo 3etaL6pf3ZUxjT2Pq4NLi9xe0h3p0Klve1MwE/m7AFjjw78z1UPxTkdW6KVSr6YB EkcMcoBwvtfq0HISfK3vjQQEjxjnepwx64iXQBs1PRNTtxowDx9vO1yyLUvkocWX qu4VSA== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 445gh60526-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:36:13 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 50E5aCok016202 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 05:36:12 GMT Received: from la-sh002-lnx.ap.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 13 Jan 2025 21:36:06 -0800 From: "Jiao, Joey" Date: Tue, 14 Jan 2025 13:34:37 +0800 Subject: [PATCH 7/7] arm64: disable kcov instrument in header files MIME-Version: 1.0 Message-ID: <20250114-kcov-v1-7-004294b931a2@quicinc.com> References: <20250114-kcov-v1-0-004294b931a2@quicinc.com> In-Reply-To: <20250114-kcov-v1-0-004294b931a2@quicinc.com> To: Dmitry Vyukov , Andrey Konovalov , Jonathan Corbet , Andrew Morton , Dennis Zhou , Tejun Heo , Christoph Lameter , Catalin Marinas , Will Deacon CC: , , , , , , X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1736832942; l=1362; i=quic_jiangenj@quicinc.com; s=20250114; h=from:subject:message-id; bh=1kWeMy8H18bHx7q6bxqI4S7xMp8TmEXRvurq+o8jSTk=; b=zPdx/wsH9uf3YlAIvy013JGGUIrnRUGzN+n5UmShLK05sjrO5Bv+UKhmFiYiSigdphGdNZ4mt wlcCgEsIO2HASI15aSluF7QMoXny39DoX3F20cozNtGxwEHgHdqrSVX X-Developer-Key: i=quic_jiangenj@quicinc.com; a=ed25519; pk=JPzmfEvx11SW1Q1qtMhFcAx46KP1Ui36jcetDgbev28= X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: SJSYjyfLnYMRCxOaFXFtA289YzGmtz-L X-Proofpoint-GUID: SJSYjyfLnYMRCxOaFXFtA289YzGmtz-L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 suspectscore=0 malwarescore=0 mlxlogscore=761 phishscore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501140044 X-Stat-Signature: tirdasegtyfb9ikfeune7zwy8tb1ntqp X-Rspamd-Queue-Id: B62BC1C0008 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1736832981-359932 X-HE-Meta: U2FsdGVkX1/r60uQY8C7XCihZrddj7dqPvVP3rpY3P0DBPh8ztWfVRWH6BjBJi3BAVIwc2JLp5PRwE0xXXgBuKMbeLkGfG7pwU1Pf7Vri3/q1C4P7KfAvthc4ftz7Bny5sqptmFdDikzCmFtAPYwUzBulXZI0ZaEj3AXUdEKkXQq+87srThELK+yNMb3HZTIGd/BPhbRgCaJfJT73S6osUn/aNoxi7ffpG4yUlf5iUcNtUyhKFVH/r0i5TvwB45B0Uj+QkqdU/+uJgcJwaWO3a3lvyyXlG3AFsdNXNnL5s3Y7bBKES/DCLCPAf+1YmJvxouu0EJYPlYMoLmIWzLtjtwlV6ySJ1H9hgvys4O5R2QQ44TlfW+UyevRgrj5oeExcNOu9TkwzSbYpjYQdq57Wt4sdZsbnf+I8oZoiMhdQybjOAueSueEiHCHRCdS+G06m+X7VjQj4uwy8sMPCSgD5ia/Ca3OoTlDu7jnmFcyM0Pu1NRlaDmlg1WCK93amqBG2LFCi3lO1fhiPTFVSpdZBDCb3kD1FAL+3R/rsxAITr0UKYWgiAYy5d0WrFWw6G7JuOdVaHRf6azVHuqRkqS4uTzZfJkerJlfxa5Dw53JmQ+LfKsiExGDwZG2jGdTGSTC6cklQ6ToKmE0P0YGVlsnr0nr7XIrKJnkBRx2DUu+HahsiFg02Vm8vOi41g5PeghSftwdccfX5WPwMOZT4yPd1QGAt4DhnlojL2uMl8iIXRNNQ8YtffCLLVZbBcZIyr1AOBUC1+Qvb/aHtAAaHTKHF8xt6qNLGIZs4DnjjqTkPHTCeBlYvvsbT4i9uv2X1Z9WTJagTAP8pDPz75IUA0T/FCozwGX6njl6UkfuBsAzXuN0mOgrmf1yIk0UnPizvDZEkRgvjLStFnP+YIbwjmx0K4wtwOPBp2i0NkWNwVYEADaR5VWdhpYas3BuoXb1pUyZKbMfU1X2V60xHAssDr+ Cgy27FRM w2b6TluC/x1VMhgyEmrdt+nMsmHJakR+CDEF2EU/u66o1avXFHiDhDI953MN0p6zA+wkdp/uEZPlZ7bhEwC2NkHHyCQuE7Pa2FFVzUjJRONjDeVGKSZ24ZCYrTh220HAXJrE90SqnEzFZKyUBhmS1mHWNkwo04lUFBx1bLM3NOUEIzadMHT1I9lFpgOGyu9Z5/aWmt7P9cojHak1YN2NtD0etEUUtztL46GsVV5tw61Gsr50Ixa5Harlxg71jGXVsxRyjYxU9mR7Yr+kafNKeWC28H1rHRoE2Eo4uaMqcRrsDA+zlNtACl0P1v92q3ucCF8XmG/LvaP2LmV0= 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: List-Subscribe: List-Unsubscribe: Disable instrument which causes recursive call to __sanitizer_cov_trace_pc Signed-off-by: Jiao, Joey --- arch/arm64/include/asm/percpu.h | 2 +- arch/arm64/include/asm/preempt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h index 9abcc8ef3087b7066c82db983ae2753f30607f7f..a40ff8168151bb481756d0f6cb341aa8dc52a121 100644 --- a/arch/arm64/include/asm/percpu.h +++ b/arch/arm64/include/asm/percpu.h @@ -29,7 +29,7 @@ static inline unsigned long __hyp_my_cpu_offset(void) return read_sysreg(tpidr_el2); } -static inline unsigned long __kern_my_cpu_offset(void) +static __no_sanitize_coverage inline unsigned long __kern_my_cpu_offset(void) { unsigned long off; diff --git a/arch/arm64/include/asm/preempt.h b/arch/arm64/include/asm/preempt.h index 0159b625cc7f0e7d6996b34b4de8e71b04ca32e5..a8742a57481a8bf7f1e35b9cd8b0fd9a37f0ba78 100644 --- a/arch/arm64/include/asm/preempt.h +++ b/arch/arm64/include/asm/preempt.h @@ -8,7 +8,7 @@ #define PREEMPT_NEED_RESCHED BIT(32) #define PREEMPT_ENABLED (PREEMPT_NEED_RESCHED) -static inline int preempt_count(void) +static __no_sanitize_coverage inline int preempt_count(void) { return READ_ONCE(current_thread_info()->preempt.count); }