From patchwork Fri Nov 9 02:39:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Farman X-Patchwork-Id: 10675251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05F3318FD for ; Fri, 9 Nov 2018 02:40:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAE4E2EB52 for ; Fri, 9 Nov 2018 02:40:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEF312EB71; Fri, 9 Nov 2018 02:40:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 730422EB52 for ; Fri, 9 Nov 2018 02:40:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727846AbeKIMSn (ORCPT ); Fri, 9 Nov 2018 07:18:43 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:51200 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727553AbeKIMSm (ORCPT ); Fri, 9 Nov 2018 07:18:42 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wA92XWmw053498 for ; Thu, 8 Nov 2018 21:40:10 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2nmwmd8aea-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 08 Nov 2018 21:40:10 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 9 Nov 2018 02:40:08 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 9 Nov 2018 02:40:05 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wA92e3Jr7143888 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 9 Nov 2018 02:40:03 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 46AE05204F; Fri, 9 Nov 2018 02:40:03 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 25BDD5204E; Fri, 9 Nov 2018 02:40:03 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id E691620F646; Fri, 9 Nov 2018 03:40:02 +0100 (CET) From: Eric Farman To: Cornelia Huck , Pierre Morel Cc: Eric Farman , linux-s390@vger.kernel.org, kvm@vger.kernel.org, Halil Pasic , Farhan Ali , "Jason J . Herne" Subject: [RFC PATCH v1 00/10] vfio-ccw channel program rework Date: Fri, 9 Nov 2018 03:39:27 +0100 X-Mailer: git-send-email 2.16.4 X-TM-AS-GCONF: 00 x-cbid: 18110902-0012-0000-0000-000002C78160 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18110902-0013-0000-0000-000020FBD301 Message-Id: <20181109023937.96105-1-farman@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-08_13:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=443 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811090022 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Connie, Pierre, This is a first round of rework to vfio-ccw that I've been cooking to make the channel program handler easier to understand. My apologies for the number of patches; as there are some intersections within them I couldn't break them up without forcing them to be applied in a particular order. I imagine that since there will probably need to be some discussion, an RFC tag makes sense and one giant series will be fine for now. I can break them up for later versions if desired. (Sidebar: I'm leaving next Thursday for an early start on the US Thanksgiving holiday. So if you are busy and can't get to this, no problem! Now where did I leave Pierre's rework patches... :) Patch summary: 1-2: Fixes for cleanup on error paths 3: Code simplication 4-6: Simplify the ccwchain processing 7-10: Simplify the pfn_array processing The first few patches are very straightforward, if unlikely to occur. They could even be considered candidates for 4.20, if so inclined. The ccwchain patches are the result of two observations about how we currently process a channel program and its component CCWs. One is a duplicate set of code for a Transfer In Channel (TIC) CCW versus any other type, which provides an easy opportunity for simplification when all it's trying to handle is a memory jump. The other is a duplication between a direct-addressed CCW and an Indirect Data Address (IDA) CCW. There is currently the nuance that the direct CCW path creates: ch_pat->pfn_array_table[1]->pfn_array[#pages] while an IDA CCW creates: ch_pat->pfn_array_table[#idaws]->pfn_array[1] It might not be obvious, but #pages is calculated identically to #idaws, as highlighted by patch 7. By removing these duplications, we set the stage for the next patches, which can eliminate an array entirely. The pfn_array patches permit a non-contiguous array of addresses to be passed to pfn_array_alloc(_pin), which in turn permits the removal of struct pfn_array_table and a squashing of our arrays. Thus, instead of either of the two nested arrays described above, we have: ch_pa->pfn_array[#idaws] (Doesn't that look nice?!) The last two patches in this series should be squashed together; I just left them apart in the RFC to make it easier to see how turn-key this becomes after the complexities of the previous patches, and without the noise of realigning the code afterward. (Sorry, kbuild robot.) While this series provides no functionality changes, I find that sizeof(vfio_ccw.ko) decreases by about 7 percent according to the bloat-o-meter, and we remove some of the malloc load for a given channel program. Hopefully there's also an increase in Readability, Understandability, and Maintainability too! Eric Farman (10): s390/cio: Fix cleanup of pfn_array alloc failure s390/cio: Fix cleanup when unsupported IDA format is used s390/cio: Squash cp_free and cp_unpin_free s390/cio: Breakout the processing of a channel program s390/cio: Use common channel program processor for TIC s390/cio: Combine ccwchain_fetch _idal and _direct s390/cio: Tell pfn_array_alloc_pin to pin pages, not bytes s390/cio: Split pfn_array_alloc_pin into pieces s390/cio: Eliminate the pfn_array_table struct s390/cio: Remove unused function/variables FIXUP drivers/s390/cio/vfio_ccw_cp.c | 416 +++++++++++++++-------------------------- drivers/s390/cio/vfio_ccw_cp.h | 1 + 2 files changed, 150 insertions(+), 267 deletions(-)