From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6BC7C4332F for ; Fri, 15 Dec 2023 05:47:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=frha1mVrK0tPnsI+rz8RZB/3G/3tnFLAMjMkry9RHkI=; b=maS9FghbWwF4Q1 7L0kF/zwP+tU9r3WLMrTOqTpNtxwPYPMqdqxFvrqWSVZFn1QvyaO6ZFNGE6HScCZY7FgvH8JHzvQt Sf5ZfiK50Z6a+OAziNJPzkR5e8BhKvjbbTi61PkurWyrcM3v0pfBr3BEVQRCxI5ivC7gd5SrM6prx gNcbYYe0TOrGKsQmZEEljrU6wMKWMD6LKKvdyJnXE3V3wBpGXB9xTQ5ExctzbfjEsJjkieP+TFG26 lz8cTty3lVG7cjW4YYqL9c0/RkvCu6dHRnxX2Irkz4vPG1Akj6FvMgpBlktIWfSoYiQQyzF9hhnWv //XUR+GdRjIyOsnj8Szw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rE12h-0026ZA-1N; Fri, 15 Dec 2023 05:47:23 +0000 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rE12b-0026WJ-2W for kexec@lists.infradead.org; Fri, 15 Dec 2023 05:47:20 +0000 Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BF4Wivg013603; Fri, 15 Dec 2023 05:46:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=G8C4JCcUHSTTyPo3/q5F0LdFKK76tWUNMSiYqbvZEPc=; b=lKTUBBTLG3A3M6ioeWGeWDIqq7KwP9emioloBv+ec0smxDPO58Uw//XbEmw27rmOFVTp /DeEU+7MKeEEcWrbrVhZVtGvyxROWnQQqI4oL4nb6leROCOk6cwiZQlJMynWAvJWKUIR 6cNYTEUfjc56ZKZk/PUDI4fbWZ/NY2iGjh2xtmcjbbihS6lXTKK3p4bAcgKcse7WldvV TkYHX97nyfPEzAFbwZTY8pllpDa7Q0/kWJKsEwC4CScQARhG7JcmrVgtcTjJZhzDDm+T QHo6Ym9YM3gx3zB2zWbsF/LA6mmqs/bOSgSXA8befSGUBNt/4r2isAAc/yUyEFCLN3ya 4g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3v0fv1hjv9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Dec 2023 05:46:43 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BF5aiSA004809; Fri, 15 Dec 2023 05:46:42 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3v0fv1hjux-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Dec 2023 05:46:42 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3BF33ApE005049; Fri, 15 Dec 2023 05:46:41 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3uw4skwkv9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Dec 2023 05:46:41 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3BF5kc4k44105986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Dec 2023 05:46:38 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 622D72004D; Fri, 15 Dec 2023 05:46:38 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 21AED20040; Fri, 15 Dec 2023 05:46:33 +0000 (GMT) Received: from [9.79.186.169] (unknown [9.79.186.169]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 15 Dec 2023 05:46:32 +0000 (GMT) Message-ID: <02622173-c9a1-425d-99b2-ba1dee802029@linux.ibm.com> Date: Fri, 15 Dec 2023 11:16:31 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v14 2/6] crash: make CPU and Memory hotplug support reporting flexible To: Baoquan He Cc: linuxppc-dev@ozlabs.org, Akhil Raj , Andrew Morton , "Aneesh Kumar K . V" , Borislav Petkov , Boris Ostrovsky , Christophe Leroy , Dave Hansen , Dave Young , David Hildenbrand , Eric DeVolder , Greg Kroah-Hartman , Hari Bathini , Laurent Dufour , Mahesh Salgaonkar , Michael Ellerman , Mimi Zohar , Naveen N Rao , Oscar Salvador , Thomas Gleixner , Valentin Schneider , Vivek Goyal , kexec@lists.infradead.org, x86@kernel.org References: <20231211083056.340404-1-sourabhjain@linux.ibm.com> <20231211083056.340404-3-sourabhjain@linux.ibm.com> Content-Language: en-US From: Sourabh Jain In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-GUID: uC2PU0LIbWEhLol4EIYDyboh6McGcCYg X-Proofpoint-ORIG-GUID: HEhJn4GifKh9x3hTUEmTcC264YDfLPUJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-15_02,2023-12-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 suspectscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312150033 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_214718_173387_8D48D9A1 X-CRM114-Status: GOOD ( 31.55 ) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "kexec" Errors-To: kexec-bounces+kexec=archiver.kernel.org@lists.infradead.org Hello Baoquan, On 14/12/23 19:43, Baoquan He wrote: > On 12/11/23 at 02:00pm, Sourabh Jain wrote: >> Architectures' specific functions `arch_crash_hotplug_cpu_support()` and >> `arch_crash_hotplug_memory_support()` advertise the kernel's capability >> to update the kdump image on CPU and Memory hotplug events to userspace >> via the sysfs interface. These architecture-specific functions need to >> access various attributes of the `kexec_crash_image` object to determine >> whether the kernel can update the kdump image and advertise this >> information to userspace accordingly. >> >> As the architecture-specific code is not exposed to the APIs required to >> acquire the lock for accessing the `kexec_crash_image` object, it calls >> a generic function, `crash_check_update_elfcorehdr()`, to determine >> whether the kernel can update the kdump image or not. >> >> The lack of access to the `kexec_crash_image` object in >> architecture-specific code restricts architectures from performing >> additional architecture-specific checks required to determine if the >> kdump image is updatable or not. For instance, on PowerPC, the kernel >> can update the kdump image only if both the elfcorehdr and FDT are >> marked as updatable for the `kexec_load` system call. >> >> So define two generic functions, `crash_hotplug_cpu_support()` and >> `crash_hotplug_memory_support()`, which are called when userspace >> attempts to read the crash CPU and Memory hotplug support via the sysfs >> interface. These functions take the necessary locks needed to access the >> `kexec_crash_image` object and then forward it to the >> architecture-specific handler to do the rest. >> >> Signed-off-by: Sourabh Jain >> Cc: Akhil Raj >> Cc: Andrew Morton >> Cc: Aneesh Kumar K.V >> Cc: Baoquan He >> Cc: Borislav Petkov (AMD) >> Cc: Boris Ostrovsky >> Cc: Christophe Leroy >> Cc: Dave Hansen >> Cc: Dave Young >> Cc: David Hildenbrand >> Cc: Eric DeVolder >> Cc: Greg Kroah-Hartman >> Cc: Hari Bathini >> Cc: Laurent Dufour >> Cc: Mahesh Salgaonkar >> Cc: Michael Ellerman >> Cc: Mimi Zohar >> Cc: Naveen N Rao >> Cc: Oscar Salvador >> Cc: Thomas Gleixner >> Cc: Valentin Schneider >> Cc: Vivek Goyal >> Cc: kexec@lists.infradead.org >> Cc: x86@kernel.org >> --- >> arch/x86/include/asm/kexec.h | 8 ++++---- >> arch/x86/kernel/crash.c | 20 +++++++++++++++----- >> include/linux/kexec.h | 13 +++++++------ >> kernel/crash_core.c | 23 +++++++++++++++++------ >> 4 files changed, 43 insertions(+), 21 deletions(-) >> >> diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h >> index 9bb6607e864e..5c88d27b086d 100644 >> --- a/arch/x86/include/asm/kexec.h >> +++ b/arch/x86/include/asm/kexec.h >> @@ -212,13 +212,13 @@ void arch_crash_handle_hotplug_event(struct kimage *image, void *arg); >> #define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event >> >> #ifdef CONFIG_HOTPLUG_CPU >> -int arch_crash_hotplug_cpu_support(void); >> -#define crash_hotplug_cpu_support arch_crash_hotplug_cpu_support >> +int arch_crash_hotplug_cpu_support(struct kimage *image); >> +#define arch_crash_hotplug_cpu_support arch_crash_hotplug_cpu_support >> #endif >> >> #ifdef CONFIG_MEMORY_HOTPLUG >> -int arch_crash_hotplug_memory_support(void); >> -#define crash_hotplug_memory_support arch_crash_hotplug_memory_support >> +int arch_crash_hotplug_memory_support(struct kimage *image); >> +#define arch_crash_hotplug_memory_support arch_crash_hotplug_memory_support >> #endif >> >> unsigned int arch_crash_get_elfcorehdr_size(void); >> diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c >> index 0d7b2657beb6..ad5941665589 100644 >> --- a/arch/x86/kernel/crash.c >> +++ b/arch/x86/kernel/crash.c >> @@ -398,18 +398,28 @@ int crash_load_segments(struct kimage *image) >> #undef pr_fmt >> #define pr_fmt(fmt) "crash hp: " fmt >> >> -/* These functions provide the value for the sysfs crash_hotplug nodes */ >> +#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_MEMORY_HOTPLUG) >> +static int crash_hotplug_support(struct kimage *image) >> +{ >> + if (image->file_mode) >> + return 1; >> + >> + return image->update_elfcorehdr; >> +} >> +#endif >> + >> #ifdef CONFIG_HOTPLUG_CPU >> -int arch_crash_hotplug_cpu_support(void) >> +/* These functions provide the value for the sysfs crash_hotplug nodes */ >> +int arch_crash_hotplug_cpu_support(struct kimage *image) >> { >> - return crash_check_update_elfcorehdr(); >> + return crash_hotplug_support(image); >> } >> #endif >> >> #ifdef CONFIG_MEMORY_HOTPLUG >> -int arch_crash_hotplug_memory_support(void) >> +int arch_crash_hotplug_memory_support(struct kimage *image) >> { >> - return crash_check_update_elfcorehdr(); >> + return crash_hotplug_support(image); >> } >> #endif >> >> diff --git a/include/linux/kexec.h b/include/linux/kexec.h >> index ee28c09a7fb0..0f6ea35879ee 100644 >> --- a/include/linux/kexec.h >> +++ b/include/linux/kexec.h >> @@ -486,16 +486,17 @@ static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { >> static inline void arch_crash_handle_hotplug_event(struct kimage *image, void *arg) { } >> #endif >> >> -int crash_check_update_elfcorehdr(void); >> - >> -#ifndef crash_hotplug_cpu_support >> -static inline int crash_hotplug_cpu_support(void) { return 0; } >> +#ifndef arch_crash_hotplug_cpu_support >> +static inline int arch_crash_hotplug_cpu_support(struct kimage *image) { return 0; } >> #endif >> >> -#ifndef crash_hotplug_memory_support >> -static inline int crash_hotplug_memory_support(void) { return 0; } >> +#ifndef arch_crash_hotplug_memory_support >> +static inline int arch_crash_hotplug_memory_support(struct kimage *image) { return 0; } >> #endif >> >> +extern int crash_hotplug_cpu_support(void); >> +extern int crash_hotplug_memory_support(void); >> + >> #ifndef crash_get_elfcorehdr_size >> static inline unsigned int crash_get_elfcorehdr_size(void) { return 0; } >> #endif >> diff --git a/kernel/crash_core.c b/kernel/crash_core.c >> index b9190265fe52..b621f03c1104 100644 >> --- a/kernel/crash_core.c >> +++ b/kernel/crash_core.c >> @@ -892,12 +892,14 @@ DEFINE_MUTEX(__crash_hotplug_lock); >> #define crash_hotplug_lock() mutex_lock(&__crash_hotplug_lock) >> #define crash_hotplug_unlock() mutex_unlock(&__crash_hotplug_lock) >> >> +#define CPU_HOTPLUG 0 >> +#define MEM_HOTPLUG 1 >> /* >> * This routine utilized when the crash_hotplug sysfs node is read. >> * It reflects the kernel's ability/permission to update the crash >> * elfcorehdr directly. >> */ >> -int crash_check_update_elfcorehdr(void) >> +static int crash_hotplug_support(int hotplug) > Is it possible that we rename this function to different name? e.g > crash_hotplug_check_support() or other name. We may easily mixing it up > with the one of ARCH version. personal opinion Sure I will rename the common function to crash_hotplug_check_support() and arch-specific function to arch_crash_hotplug_check_support. Thanks, Sourabh > >> { >> int rc = 0; >> >> @@ -909,18 +911,27 @@ int crash_check_update_elfcorehdr(void) >> return 0; >> } >> if (kexec_crash_image) { >> - if (kexec_crash_image->file_mode) >> - rc = 1; >> - else >> - rc = kexec_crash_image->update_elfcorehdr; >> + if (hotplug == CPU_HOTPLUG) >> + rc = arch_crash_hotplug_cpu_support(kexec_crash_image); >> + else if (hotplug == MEM_HOTPLUG) >> + rc = arch_crash_hotplug_memory_support(kexec_crash_image); >> } >> /* Release lock now that update complete */ >> kexec_unlock(); >> crash_hotplug_unlock(); >> - >> return rc; >> } >> >> +int crash_hotplug_cpu_support(void) >> +{ >> + return crash_hotplug_support(CPU_HOTPLUG); >> +} >> + >> +int crash_hotplug_memory_support(void) >> +{ >> + return crash_hotplug_support(MEM_HOTPLUG); >> +} >> + >> /* >> * To accurately reflect hot un/plug changes of cpu and memory resources >> * (including onling and offlining of those resources), the elfcorehdr >> -- >> 2.41.0 >> _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec