Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp442019iog; Mon, 13 Jun 2022 06:05:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRX4di3GohKvE/r0Gimvtrz9zJcbfoU6sYuNravLPmgsqtTKGELSEflPOLmXqVTcmLfomG X-Received: by 2002:a05:6402:23a2:b0:42d:d5f1:d470 with SMTP id j34-20020a05640223a200b0042dd5f1d470mr51457482eda.365.1655125444242; Mon, 13 Jun 2022 06:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125444; cv=none; d=google.com; s=arc-20160816; b=POZQ3gbkmBKSoP309uscx4FMrsWBJIGNvBsPs/fo04vFX1vWHYgeOYEMj4Wog0OCEw AYyipT2NHhstv3hlIqxgtw8ZaC+9w2e3ckvLxqOS/pAXyJmFTRZlNJKMT4JM87Uo6kYK tkWOnZjR74zNxHrFxYRKClDzJ4K0csc6ma0rqRNNakp4GWIALnqHRJWv9qWnaGPTx1bL n6dJYcqcvqw6YxuLF7WCvvM5UGVykrA5Gv9NnG/z6QFj9QycVBPdVMyyiABF0tPqXbB2 TFFvEn7YYG1rZRGCFDMisjVPXi3alPqmBUYMLF/1VWXj0AlWIGBZlJtNXGgzM/K6Jksn WIBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2d+WxizpaLlDnOBnXzaZfUTg7g70ZXjhLWiXFp78/1o=; b=SGr90JiIVQdSthOklBoS16Ux8+3fZs1rhxqDz0V3PaYqdu7svFfkDtuHMzdQk7s9WR wQeChdocOvTBxLShsBcRzh6okfamqtgcR2dn0RcElNlopxShvWFP2dWkXS61sDE3U/6O F/90OOSIJiuN54N2zYaOKR61oOU93I2HLz1oshQ5HNo0APZBQaC+tmBwSx4HTNoEUdMq fVnFp1/bfucUBOCCU9L/3XFubq1FcGOLi12EuIDXcVcOh76jqVHHQ1T0oWElVGpfYRcL j9bd4jvLF9F6RZ0Qv2RqP7q3NZv0ZK17mFKRISR4u8tKopFiVuH2Oo+pHEKhC9vt06K1 422Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lPUabr5v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020a17090627c400b006feed02de33si7049061ejc.481.2022.06.13.06.03.36; Mon, 13 Jun 2022 06:04:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lPUabr5v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356866AbiFMLvs (ORCPT + 99 others); Mon, 13 Jun 2022 07:51:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357430AbiFMLqH (ORCPT ); Mon, 13 Jun 2022 07:46:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22EE4C30; Mon, 13 Jun 2022 03:52:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 57C74B80D3C; Mon, 13 Jun 2022 10:52:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B409EC3411E; Mon, 13 Jun 2022 10:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117533; bh=WYtg6yUY6yiewaqifDNtJ9l3eq/l+7QgrMV3SgSnmtw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lPUabr5vD1rooOgl7b9wbmGmOAawmW/x83tpGWo60KSbfDsDnNQFFAq7uz09WIS4k ax+FdFtd7q5byKBTw/Dkg4xIyyTl9we4hWzKYhSXFdbhczW3hOMezGegVdEXlgQRit Gdj8zAb9cz55si/zqz111w+mWlT8A3DaXuuMnFSw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Borntraeger , Alexander Gordeev , Claudio Imbrenda , Heiko Carstens , Sasha Levin Subject: [PATCH 5.4 395/411] s390/gmap: voluntarily schedule during key setting Date: Mon, 13 Jun 2022 12:11:08 +0200 Message-Id: <20220613094940.510234361@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christian Borntraeger [ Upstream commit 6d5946274df1fff539a7eece458a43be733d1db8 ] With large and many guest with storage keys it is possible to create large latencies or stalls during initial key setting: rcu: INFO: rcu_sched self-detected stall on CPU rcu: 18-....: (2099 ticks this GP) idle=54e/1/0x4000000000000002 softirq=35598716/35598716 fqs=998 (t=2100 jiffies g=155867385 q=20879) Task dump for CPU 18: CPU 1/KVM R running task 0 1030947 256019 0x06000004 Call Trace: sched_show_task rcu_dump_cpu_stacks rcu_sched_clock_irq update_process_times tick_sched_handle tick_sched_timer __hrtimer_run_queues hrtimer_interrupt do_IRQ ext_int_handler ptep_zap_key The mmap lock is held during the page walking but since this is a semaphore scheduling is still possible. Same for the kvm srcu. To minimize overhead do this on every segment table entry or large page. Signed-off-by: Christian Borntraeger Reviewed-by: Alexander Gordeev Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20220530092706.11637-2-borntraeger@linux.ibm.com Signed-off-by: Christian Borntraeger Signed-off-by: Heiko Carstens Signed-off-by: Sasha Levin --- arch/s390/mm/gmap.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index 5e5a4e1f0e6c..19ee8355b2a7 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -2579,6 +2579,18 @@ static int __s390_enable_skey_pte(pte_t *pte, unsigned long addr, return 0; } +/* + * Give a chance to schedule after setting a key to 256 pages. + * We only hold the mm lock, which is a rwsem and the kvm srcu. + * Both can sleep. + */ +static int __s390_enable_skey_pmd(pmd_t *pmd, unsigned long addr, + unsigned long next, struct mm_walk *walk) +{ + cond_resched(); + return 0; +} + static int __s390_enable_skey_hugetlb(pte_t *pte, unsigned long addr, unsigned long hmask, unsigned long next, struct mm_walk *walk) @@ -2601,12 +2613,14 @@ static int __s390_enable_skey_hugetlb(pte_t *pte, unsigned long addr, end = start + HPAGE_SIZE - 1; __storage_key_init_range(start, end); set_bit(PG_arch_1, &page->flags); + cond_resched(); return 0; } static const struct mm_walk_ops enable_skey_walk_ops = { .hugetlb_entry = __s390_enable_skey_hugetlb, .pte_entry = __s390_enable_skey_pte, + .pmd_entry = __s390_enable_skey_pmd, }; int s390_enable_skey(void) -- 2.35.1